2016-07-16 33 views

回答

0

根据this下面的代码应该适用于去除PHP扩展。

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L]

+0

此代码删除了整个扩展,这反过来又重定向我的RewriteBase。我只需要删除.php文件。 – SLV

+0

我是一种新的stackoverflow。你能告诉我如何把我的“有问题的代码”到正确的格式/文本编辑器? – SLV

0

要完全删除PHP扩展,你可以使用以下规则:

RewriteEngine on 
#1 redirect "/file.php" to "/file" 
RewriteCond %{THE_REQUEST} ([^.]+)\.php [NC] 
RewriteRule^%1 [L,R] 
#2 internally map "/file" back to "/file.php" 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*?)/?$ /$1.php [L] 
+0

这些规则都不起作用。 – SLV