2016-08-05 49 views
0

將尾部反斜槓添加到URL末尾會導致錯誤500,即/ forum /。當輸入/論壇時,/forum.php按預期加載到瀏覽器中。在檢查錯誤日誌文件時,其狀態爲添加尾部反斜槓導致錯誤500

由於可能的 配置錯誤,請求超出了10個內部重定向的限制。如有必要,使用'LimitInternalRecursion'來增加 的限制。使用'LogLevel debug'來獲得回溯。

Options +FollowSymLinks -MultiViews 

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(admin|user)($|/) - [L] 


#RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME}.php -f 

RewriteRule ^(.*)$ $1.php [L] 
RewriteRule ^([A-Za-z0-9-_]+)$ /index.php?view=$1 [L] 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)$ index.php?view=$1&page=$2 [L] 

如果我添加一個反斜槓 '?/',/論壇將加載索引頁/論壇/將加載/forum.php

RewriteRule ^(.*)?/$ $1.php [L] 

我有什麼錯?先謝謝你。

回答

0
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [L] 

這個RewriteCond條件應該防止在所請求的文件存在的情況下重寫。在你的情況下,/forum將被重寫爲/forum.php,然後重寫的請求被傳遞迴URL解析引擎,該引擎將會發現/forum.php存在,並且此規則不會再次被執行。

當你請求/forum/,它改寫爲/forum/.php不存在的,所以如果你能夠重寫它改寫爲/forum/.php.php等,你可以SE這在錯誤日誌logging

速戰速決將剝離trailin斜槓(把它放在下面RewriteBase /

RewriteRule ^(.*)/$ /$1 [NC,L]