I currently have all my pages working without their .php extensions by using mod_rewrite. Such as:
www.mywebsite.com/noextension
However, how would I go about redirecting my users to a 404 page if they decide to add the .php extension to the url like this?
www.mywebsite.com/noextension.php
My htaccess looks like this so far:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9]+)(/)?$ $1.php
RewriteRule ^forums/([a-zA-Z0-9]+)(/)?$ forums.php?category=$1 [NC]
I have tried things such as this RewriteRule .php$ - [R=404]
, however, it just 404's every single page I go to. I assume I might have to use something like REQUEST_URI to do what I am asking.
What do you guys suggest I add? Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…