I am in the process of re-building my private blog. I now want to use a hoster with PHP. However, I would like to hide the .php extension and use .html instead. On the other hand, the hoster requires a rewrite to .php to actually run the scripts. So I would like to:
Externally redirect any request for a
.phpto the corresponding.htmlURL, so the user does not "see" the PHP URL.Internally rewrite any request for a
.htmlfile to a.phpfilename to execute the actual PHP script.
The hoster uses Apache with mod_rewrite as far as I can tell.
Basically what I think I need is:
RedirectEngine On
RedirectMatch 301 ^(.*).php$ $1.html
RewriteRule ^(.*).html$ $1.php [L]
However, I get an infinite redirect loop to the .html file. As if the RewriteRule automatically triggers the RedirectMatch again.
I also tried various combinations of RewriteRule, RewriteCond and RewriteBase instead of the RedirectMatch, but the redirect then usually goes to some hoster-internal directory structure (like /bla/foo/user/xyz/.../file.html), and RedirectBase shows no effect.
Any help is appreciated!