2

我的 htaccess 规则不起作用
我不想显示 php 扩展
我的规则

Options +FollowSymlinks -MultiViews -Indexes  
RewriteEngine on  
RewriteBase /  
RewriteRule ^WHMCS/?$ 404.php [L]  
RewriteRule .*\.php$ 404.php [L]       
RewriteRule ^contact$ /contact.php  [L]
RewriteRule ^p/([a-zA-Z0-9_-]+)/?$ ./page.php?page=$1 [L] 
RewriteRule ^comments$ ./comments.php [L]  

但是当我打开没有任何扩展名的 url 时,它也会向我显示 404 错误
,提前谢谢

4

1 回答 1

0

注释掉这条规则:RewriteRule .*\.php$ 404.php [L]并在你的规则末尾使用这条规则

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
于 2013-11-03T10:41:32.137 回答