問題:的.htaccess做一個子文件夾的主域的主文件夾,但是當URL直接輸入到瀏覽器中獲取冗餘重定向
我使用的.htaccess做一個子文件夾主文件夾我的主域。 一切似乎工作正常,但我注意到,當我直接鍵入一個URL,如「primarydomain.com/blog/」, 它重定向到「http://primarydomain.com/primarydomain.com/blog/」 。
詳情:
目前,我有相同的網站主辦的帳戶下的多個領域。 這個虛擬主機提供商最初舉辦我的文件作爲:
- 的public_html /所有webfiles爲我的主域名(primarydomain.com)
- 的public_html/domain2.com /所有webfiles我的其他領域之一
- 的public_html/domain3.com /所有webfiles我的域
使用.htaccess文件和重寫規則的另外一個,我已經能夠重新整理我的文件安心爲:
- 的public_html/primarydomain.com/
- 的public_html/domain2.com/
- 的public_html/domain3.com/
...有說在根目錄下的.htaccess文件:
- 的public_html /的.htaccess
此.htaccess文件如下:
<IfModule mod_rewrite.c>
RewriteEngine On
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?primarydomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/primarydomain.com/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /primarydomain.com/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?primarydomain.com$
RewriteRule ^(/)?$ primarydomain.com/ [L]
# this last line I commented out because it was causing all the links (direct links) to all my files to hit 404 errors
# I have included this line as a reference because it was in the original tutorial I used
# RewriteRule ^(.*)(/)?$ primarydomain.com/$1 [L]
</IfModule>
我使用的教程: http://support.lunarpages.com/knowledge_bases/article/549 (我不使用Lunarpages的,但結構是一樣的)
我不知道我在做什麼錯。任何提示/技巧將不勝感激。謝謝!
您的.htaccess文件中的大部分規則都不正確,並且很難說出您的意圖。如果你可以說明你的意圖,那麼幫助你更容易 – 2011-12-15 20:53:40
@UlrichPalha整段代碼是爲該主域創建子文件夾public_html/primarydomain.com/my主文件夾。它也遵循我已經鏈接到底部的教程。如果任何htaccess規則不正確,請解釋。 – Jay 2011-12-15 21:03:37