我有以下重写规则:
RewriteEngine On
RewriteRule ^test test.php [NC,L]
这允许我通过以下方式访问页面:
http://www.example.com/test
和http://www.example.com/test.php
但我如何防止http://www.example.com/test.php
被访问?
谢谢
如果要在直接访问forbidden error
uri时显示403 /test.php
页面,可以使用以下规则:
RewriteCond %{THE_REQUEST} /test\.php [NC]
RewriteRule ^test\.php$ - [R=403,L]
如果要将/test.php
重定向到新的uri /test
,请使用以下命令:
RewriteCond %{THE_REQUEST} /test\.php [NC]
RewriteRule ^test\.php$ /test [L,R]