我想在浏览器中隐藏要显示的文件扩展名,就像http://www.example.com/dir/abc.php
应该只显示一样http://www.example.com/dir/abc
。
我写了以下 rewriteCond 和 rewrite rule on.htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]
但这段代码似乎对我没有帮助。
编辑:这是我的 htaccess 文件的完整代码
Options -Indexes
ErrorDocument 403 /errors/403.php
ErrorDocument 404 /errors/404.php
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?127.0.0.1 [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?127.0.0.1.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC]
RewriteRule \.(js|css|jpg|png)$ - [F]
RewriteEngine on
RewriteRule ^(.*)\.[\d]{10}\.(css|js|png|jpg)$ $1.$2 [L]
RewriteEngine On
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]