我对.htaccess进行了以下编辑,以隐藏文件结尾。
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\.php
RewriteRule ^ /%1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
自从进行此编辑后,每当我转到顶部主页时,例如我得到以下错误 -
The requested URL /.php was not found on this server.
虽然这适用于我的子页面,例如example.com/about.php成为example.com/about
答案 0 :(得分:0)
您要查找的用于删除网址中.php扩展名的代码是:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]