Parse .html as PHP with Apache

  • Avinash
  • 3
  • Jan 29, 2013
  • Web Server

When we install PHP with Apache, Apache will be able parse files with .php extension and execute the same.

But in Apache we can tweak configuration in that way so Apache start to parse other file extension as php file.

In this article we will see how we can instruct Apache to parse .html file as a php file.

This tweak we can perform at three places:

  1. At Apache Global Virtual Host
  2. At Individual Virtual Host
  3. .htaccess

In Apache if you want to add support for parsing .html as php file then you will need to place below at any of the above place.

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

So this is not limited to just .html, you can add any extension you want in place of html.

Related Posts

Written by Avinash

Avinash Zala currently working at a leading web development company as a Sr. PHP Web Developer. He is the founder of the Xpert Developer. He has completed B.E. in Information Technology. Born and brought up in Ahmedabad. He loves to code and coding is all about passion for him. Follow him on twitter at Avinash Zala & Xpert Developer.

View all posts by:

  • MM

    Can we do the same with any file extension? So for example If I want my own file extension like .mm, will that work with this trick????

    • Darshan

      It should work, as i am running my own extensions .do & .inc on my server.

      • MM

        thanks for getting this clear…. :)