How to get Apache to parse HTML files as PHP

February 26, 2008 on 11:18 am | In internet, linux |


PHP is a language that is parsed and interpreted by the Apache web server. That is, all code execution takes place on the server side, not on the client side.

By default, Apache only parses files ending in extension .php as PHP files. If you need to tell Apache to also process files with other extensions as PHP files, you need to add a special handler to the Apache config files. Problem is, most individuals on shared hosting setups don’t have access to these files. Fortunately, there is a way around this.

To tell Apache to parse HTML files just like it does PHP files, you need only create a file called .htaccess (note the dot) in your root web directory. In that file, include the following line:

AddType application/x-httpd-php .html

It’s that simple!

Like this story? Share with others on:
      del.icio.us    digg    reddit    furl
      

Technorati Tags

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. EoE,

    Thanks. I should have known this but this is a great little reminder to enable this as well as other types i.e. AddType application/x-gzip .gz .tgz

    All the best.

    Comment by David — March 13, 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^
40 queries. 0.184 seconds.