I have read more than 3 questions here in stackoverflow about this, but all of them has one of the below problems:
- It redirects php to htm (not found appears, I already have php files in place)
- When you type *.htm, it will be redirected to *.php (I want visitors to see *.htm not *.php)
Let me boil it down for you guys: I need to type index.htm and apache redirects that to .php but in the address bar I still want to see .htm not .php
Any help or suggestion would be appreciated.
Please review http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule for all of the available options, including other flags you may want to include – such as
QSA.Note that the
RewriteEngine online (as well asOptions FollowSymLinks– see the docs linked to above) is necessary if you don’t already have it elsewhere. You may also needAllowOverride FileInfoin your primary Apache configuration to enable the use of.htaccessfiles.Note that the
PTflag is not strictly necessary, as it is the default if Apache determines it can fulfill the request without a redirect.Here is another result I just found from a Google Search that shows pretty much the same thing I’m describing here: http://corz.org/serv/tricks/htaccess2.php (specifically shows some rules around the .htm -> .php translation.)