Someone asked me today for help with their PHP website. He was trying to parse HTML files as PHP on his Apache webserver. This is very easy to do using the .htaccess file but he just could not seem to get his files to parse using the instructions he found on Apache’s website:
AddType application/x-httpd-php .html
The thing to remember with something as diverse as Apache and PHP, different hosts will have different configurations. For example, some hosts runs both PHP4 and PHP5. In this case, he was hosting the company website through HostGator. This is what had to be added to the htaccess file to get it to correctly parse the files:
AddHandler application/x-httpd-php5 .html .htm
With other hosts, you can get away with:
AddType application/x-httpd-php .html .htm
or
AddHandler application/x-httpd-php .html .htm
or
AddHandler x-httpd-php .html .htm
And still yet, some hosts require both AddHandler and AddType directives for it to work correctly:
AddType application/x-httpd-php .htm .html
AddHandler x-httpd-php .htm .html
Hope this helps. Leave a comment if you have any questions.
Jason Samuel is a visionary product leader and trusted advisor with a proven track record of shaping strategy and driving technology innovation. With extensive expertise in enterprise end-user computing, security, cloud, automation, and virtualization technologies, Jason has become a globally recognized authority in the IT industry. His career spans consulting for hundreds of Fortune 500 enterprises across diverse business sectors worldwide, delivering cutting-edge digital solutions from Citrix, Microsoft, VMware, Amazon, Google, and NVIDIA that seamlessly balance security with exceptional user experiences.
Jason’s leadership is amplified by his dedication to knowledge-sharing as an author, speaker, podcaster, and mentor within the global IT and technology community. Recognized with numerous prestigious awards, Jason’s contributions underscore his commitment to advancing technology and empowering organizations to achieve transformative results. Follow him on LinkedIn.
Thanks a lot for this article!
Hi Jason, I read your blogs and its quite good and eye opening for me. I need an input from…
I'm with Richard Powell and Andreas Mariotti. Things work if I do it the USB redirection way, but not with…
We see this behaviour with 2203 CU2 VDAs and while being happy, that there is at leasy an workaround without…
Saved my butt without playing around over dozens attempts to get that certificate installed! Thank you! <3 Chris