Workaround if your host doesnt support apache handler after migration using .htaccess
Workaround if your host doesnt support apache handler after migration using .htaccess
.htaccess is always a life saver for most of the web developers who are using shared web hosting. There are instances in which we need to run php inside a .htm or .html extension webpage. And it sometimes after you have migrated your web hosting service to a new hosting provider you will come across issues where they do not support apache handlers. Many of my users have faced the same. These kind of issues happen on shared web hosting services. Handlers like
AddHandler application/x-httpd-php5 .htm AddType application/x-httpd-php5 .html
will not do the trick if your host has disabled it. Even adding of handlers through cpanel won’t work. What you will do in that case. You cannot simply migrate your website to yet another host since there is money and downtime constrains. So what will be the work around for this.
You cannot simply go to different links and change the webpages from .htm / .html extensions to .php if the website is huge and lot of coding to be done again. It will become a mess sometimes. If you still want to hide the .php extensions then the only possible method is to use URL rewriting availabe through .htaccess. For this you have to rename the files that are having .htm / .html or any other extensions to .php and add this two lines inside .htaccess file
Options +FollowSymlinks RewriteEngine on RewriteRule ^(.*)\.htm$ $1.php [nc] RewriteRule ^(.*)\.html$ $1.php [nc]
You should replace
RewriteRule ^(.*)\.<REPLACE_YOUR_EXTENSION>$ $1.php [nc]
and add it with your own customized extension inside the .htaccess file.
How it works?
When a URL like http://