我有以下删除php扩展的规则
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ en/$1.php [NC,L]
现在有了这些规则,当我访问domain.com/abc时,它可以工作。但问题是,当我手动访问domain.com/abc.php时,它也有效。
我想要的是domain.com/abc.php也应该重定向到domain.com/abc。
我怎样才能做到这一点?
简而言之,无论如何我想删除php扩展。
答案 0 :(得分:0)
您可以添加规则,它会将所有* .php重定向到没有扩展名的uri-s:
RewriteRule ^(.*).php$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ en/$1.php [NC,L]