Connect with us

Hi, what are you looking for?

Apache

How to parse HTML files as PHP on an Apache web server

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:

Advertisement. Scroll to continue reading.

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:

Advertisement. Scroll to continue reading.

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

Hope this helps. Leave a comment if you have any questions.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Apache

Today I would like to go over proper URL redirection when using SSL but first I would like to preface this by describing what...

Exchange 2003

A useful Exchange 2003 guide I wrote for a friend’s blog originally but I am posting it here on mine now for your viewing...

Citrix Workspace

You can use FIDO2 hardware security keys plugged into your physical desktop over the Citrix HDX remoting protocol for use with virtualized Windows Desktop...

Cloud Design Architecture

The community-driven paperback book initiated by my friends Bas van Kaam and Christiaan Brinkhoff is available for sale on Amazon. If you haven’t picked...

Advertisement

JasonSamuel.com was launched in 2008 as a platform to give back to the IT community by sharing knowledge and expertise. Over the years, it has become a trusted global resource for the latest insights, how-to guides, and thought leadership on enterprise mobility, security, virtualization, cloud architecture, automation, and other cutting-edge technologies. Today, it serves as a go-to reference hub for IT professionals, attracting hundreds of thousands of unique visitors from around the world each month. Learn more on the About Me page.
Copyright © 2008-2025 JasonSamuel.com