1
當我的.htaccess文件出現某種情況時,會創建某種規則循環。這是有問題的代碼:.htaccess內部重定向問題
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
RewriteRule ^(.+)/?$ /%1.php?o=$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ [NC]
RewriteRule ^$ /%1.php [L,NC,QSA]
</IfModule>
通常情況下這樣做是:
test.example.com -> example.com/test.php
test.example.com/test2 -> example.com/test.php?o=test2
那很好,除了在「測試」子域的一部分指向一個不存在的文件,我得到一個內部重定向錯誤,具體如下:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: [retracted]
任何幫助表示讚賞。
謝謝,這個工作(我真的不擅長與理解的htaccess很抱歉,如果這是一個很明顯的答案) – lemondrop 2014-11-23 16:24:26
很高興它的工作,沒有它不是那麼明顯:) – anubhava 2014-11-23 16:59:04