My web site uses PHP pages internally, but I want all references to appear as HTM pages to the end user. I am currently using the following rewrite rule which works nicely for this:
RewriteRule ^(.*)\.htm$ $1.php [NC,L]
Unfortunately, if the user goes directly to a PHP page, it bypasses the rewrite rule above. The result is duplicate pages in Google listings and other sites:
sample.htm
sample.php
The code above works great for rewriting HTM pages, but I want to redirect other requests to the HTM version (which is then rewritten internally to serve a PHP page). For example:
sample.htm
sample.php
sample.asp
sample.html
sample
Should all redirect to:
sample.htm
Which should actually serve the internal sample.php page.
Any idea how I would accomplish this?