Parse HTML as PHP ( htaccess way – Different Ways )
During the development tenure, most of the developers do sometimes face the challenge of assigning one file-type to be executed by some other type’s parser.
Executing HTML files as PHP is one such example. When I faced this scenario, some
.htaccess handling instructions worked on one server but didn’t on another. Hence I decided to enumerate some possible variants of such commands.
Sometimes the following would suffice.
RemoveHandler .html .htm
AddType application/x-httpd-php5 .htm .html
But sometimes the following…
#Either this one
AddHandler application/x-httpd-php .html .htm
AddHandler x-httpd-php .html .htm
#Or this one
AddHandler application/x-httpd-php5 .html .htm
AddHandler x-httpd-php5 .html .htm
#Or this one
AddHandler application/x-httpd-php54 .html .htm
AddHandler x-httpd-php54 .html .htm
Or just assigning the type rather than handler would suffice.
AddType application/x-httpd-php .html .htm
AddType x-httpd-php .html .htm
#Or may be this one
AddType application/x-httpd-php5 .html .htm
AddType x-httpd-php5 .html .htm
#Or may be this one
AddType application/x-httpd-php54 .html .htm
AddType x-httpd-php54 .html .htm
But sometimes you might have to provide the actual path to
PHP (confirm the path from your Hosting Service provider).
AddHandler fcgid-script .html
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
Okay, let me repeat! This article is meant to enumerate the variants, not describe them. Please Google for description as I am not actually interested in copy-paste the definitions & explanations over here (At least not this time 😉 )