2016-04-29 120 views
-1

誰能幫我弄清楚爲什麼我收到此錯誤,下面是我的htaccess重定向循環錯誤刪除.PHP

RewriteEngine ON 
RewriteRule ^(.*)\.php$ /$1 [R=301,L,END] 
RewriteRule ^([^\.\/]+)$ /$1.php [QSA,L] 
+0

什麼是錯誤?您可能需要查看[如何提問],瞭解如何在此處提出可回答的問題的一些提示。 – scotthenninger

+2

[Remove .php extension with .htaccess]可能的重複(http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – starkeen

回答

0

你的第一條規則可能不需要END但第二個規則肯定會需要END標誌停止無限重定向。您可以在Apache 2.4中使用以下規則:

RewriteEngine On 

RewriteRule ^(.+)\.php$ /$1 [R=302,L,NE,NC] 

RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.+?)/?$ $1.php [END]