Hi,
I am trying to get rid of the .php extension in all of a site's URI's using the following rewrite:
RewriteCond %{REQUEST_URI} !^(.*)/$
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule !(\.)(.*)$ %1.php [L]
Whilst the above does work, it brings with it 1 problem and 1 impracticality, the two of which would hopefully be resolved simultaneously:
The problem
The problem is that if the extensionless URI belongs to a valid directory name, it returns a 404 instead of adding a slash to return the directory.
The impracticality
The impracticality is that many people might not realise that a URI has a slash at the end or not and they might key the URI in with or without the slash. Keying it in with the slash would return a 404 if a directory didn't exist.
The best solution in my opinion, if possible, would be to use a rewrite to redirect slashed uri's to their non-slash equivalet.
Then to use another rewrite to do the following:
1. If I add ".php" to this request and it resolves to a real file, then show the real file.
2. Otherwise, if i add a slash and it resolves to a real directory, then show the directory's index file instead.
I hope you can help.
Many thanks