2016-07-16 31 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