Yes, I have read other similar questions on SO about this, which is how I came up with this possible solution:
# Turn on the mod_rewrite engine
RewriteEngine On
# IF the request filename with .php extension is a file which exists
RewriteCond %{REQUEST_FILENAME}.php -f
# AND the request is not for a directory
RewriteCond %{REQUEST_URI} !/$
# Redirect to the php script with the requested filename
RewriteRule (.*) $1\.php [L]
This works by rewriting a request for, for example: /about-us to about-us.php but it doesn't work if you go to /about-us/.
I tried the below but it didn't work:
# Redirect to the php script with the requested filename
RewriteRule (.*)/? $1\.php [L]
Does it have anything to do with the second RewriteCond?
Basically I am wanting it to fail (if possible) if the request is for a real file OR directory, but if neither exist than it should rewrite to a PHP script whether the request has an ending slash or not.
Can this be done?