我的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]
但是当我打开网址而没有任何扩展时,它也显示我404错误
提前谢谢
答案 0 :(得分: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]