Process .html as PHP

Posted in Apache, PHP | By LGR | On February 7th, 2007

Hanging out at web master forums I am amazed at the number of times I come across posts asking how to process .html files as PHP. Often the question is being asked because they want to start using php to include parts of their template instead of creating static .html files. Well here is a little piece of code that has saved me countless hours, especially when moving a static .html files site to a dynamic PHP site.

To setup a Linux server running Apache web server to process .html (.htm) files as PHP. create an .htaccess file in the root folder of your website and add these lines to the .htaccess file:

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

As long as your server has been told to process .htaccess files this will tell the Apache web server to process all .htm and .html files now as php files. This now allows you to include other php files, use variables and all kinds of PHP programming on your old static .html files.

Similar Posts:

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • email
  • FriendFeed
  • Reddit
  • RSS
  • Twitter
  1. [...] if you have setup your server to process .html files as php then your server will process PHP includes that you have in your Blogger template file. Find the [...]

Leave a Reply

COMMENT


My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
  • Great debate, ideas, criticism and colorful commentary is always appreciated and approved!
«
»