mod_rewrite错误404,如果.php

8 php mod-rewrite

我重写我的网址是用户友好的.例如,我有一个名为user.php的页面,我将其重写为/ user.但是用户仍然可以使用user.php.如果他们请求扩展名为.php的网页,我可以重定向到404吗?

Options -MultiViews +FollowSymlinks -Indexes
RewriteEngine on


RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

谢谢.

cle*_*tus 7

RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
Run Code Online (Sandbox Code Playgroud)