Adding php to and HTML page: application/x-httpd-php5 vs application/x-httpd-php

Yes there is a difference. I was trying to parse php code in a file with a .html extension. So I do what I always to and look to the web for the syntax on how to edit my .htaccess file. However, pretty much every website will tell you to add one of the following lines:

AddHandler application/x-httpd-php .html .htm


AddType application/x-httpd-php .html .htm

However some web-hosts (including mine) require you to define specifically  that you are using php5. So instead of the above lines of code you have to include one of the following

AddHandler application/x-httpd-php5 .html .htm


AddType application/x-httpd-php5 .html .htm


If you don’t include the php5 (for my host at least), it will not work. It is an incredibly frustrating nuance that not many posts and forums do not cover. So, if you are trying to execute php inside of a html page using your .htaccess file and are having problems you might try adding the 5 to the end of php. Funny thing is I am pretty sure I had the same problem a while back but forgot the solution.

A great post which goes into detail regarding which code you should be using can be found here

Comments are closed.