Forum Moderators: phranque
AddHandler cgi-script .html
DirectoryIndex home.html
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*) $1\.html [L]
RewriteRule ^(.*)\.shtml $1 [R]
RewriteRule ^(.*)\.php $1 [R]
Why the .php and .shtml rules you may ask? Well the site started out as .shtml, then I learnt .php, then I learnt mod_rewrite. I want clean urls and on my newly installed apache web server (for home testing), the above is great. If a user had a bookmark with a .php or .shtml end to it, it would redirect to the (php parsed) html clean urls. As I said the above code is fine at home and even on my web hosts server.....until you add a .php or .shtml extension to the clean extension free url.....when it decides to add extra slash. So:
www.example.co.uk/rbarn
when .php added
www.example.co.uk/rbarn.php
hit enter and becomes
www.example.co.uk//rbarn
It's so close, but not good enough, because when you link to other pages in different directories it chucks up a file not found error.
So what do I have to do to
RewriteRule ^(.*)\.shtml $1 [R]
RewriteRule ^(.*)\.php $1 [R]
to sort out this problem. Perhaps something to do with the (.*)?
Many thanks,
R
[edited by: jdMorgan at 6:27 pm (utc) on Aug. 24, 2004]
[edit reason] Removed specific URLs per TOS [/edit]