开发者

Rewrite an URL and also block the file extension?

Is it possible to rewrite an url and also block the file开发者_如何学运维 extension?.

eg: if I have

`http://www.example.com/search.php?...`

can I rewrite it to

`http://www.example.com/search?` ?

but, blocking the access to the .php file, normally I can access with both ways, with and without the file extension, but I want it to show an error page or 404 if I access with search.php.

Is it possible?.

Thanks.


RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} .*\.php
RewriteRule ^(.*)$ error404.html [R=404]


Please consider using the following config:

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]

RewriteRule ^(.*)\.php$ error404.html [R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜