I have a number of rules governing the URLs on my main website & it's a pretty nice setup. There is an unintended consequence that has come up though. My latest addition cleans up a bunch of 500 errors and allows nonsense URLs to redirect a default page instead.
I need to direct some such URLs to 404 instead but I'm having trouble getting the rule to work. Here is the working rule as it stands right now. I'd like a version of this that directs the request to 404 instead given a specific page.php.
This version effects anything ending with .php/ which might be ok but it would be nice to see one configured for only a single, specific file. Also I'm thinking the redirect in the 1st rule should probably be 301 no?
## STRIP ANYTHING AFTER .php/ ##
RewriteCond %{THE_REQUEST} /([^.]+)\.php/? [NC]
RewriteRule ^ /%1/ [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /$1.php [L,NC]