Welcome to WebmasterWorld Guest from 188.8.131.52
I am using AddHandler to make .html render as PHP files. I wish to change that into a URL rewrite but I am not good at regex and mod_rewrite stuff. I wish to remove the add handler and do some kind of rewrite that makes all *.html really display *.php
Optional to read long story why I want to do this:
I use cPanel servers with several websites and many with custom file extension, or using .html to be rendered as .php by using AddHandler in my .htaccess file. In older Apache versions I used to use AddType.
Now that I have moved over to several VPS servers instead of a dedicated, I have less control on the server, but I put all my eggs in several baskets and minimizes problem websites during downtime issues.
One thing I noticed though with cPanel is whenever they upgrade it, or recompile Apache, for some reason it comments out all # AddHandler lines in all .htaccess files in all accounts. And since these hosting companies don't always tell us when this happens, I just suddenly get complains from everyone.
This seems to be the only line cPanel comments out during upgrades. So I was thinking of doing a rewrite solution instead so I touch the sites less often when these not anticipated cPanel upgrade happens.
might do, but that is usually very inefficient.
might be it. It depends on the exact format of the URLs you want.
However, instead of using .html URLs you could also consider going extensionless.
Don't forget to change the links on your pages to use the new format of URL. It is links that 'define' URLs.
You will also need a redirect placed before the rewrite such that if anything requests a .php URL, they are redirected to the correct new URL. Failure to add the redirect will lead to both URLs being available to be indexed by search engines. You do need to solve that Duplicate Content issue. Do make sure that you also force the www at the same time in the same redirect for those URLs.