Process .html as PHP
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.
Comments
LGR Webmaster Blog - Blogger Label List for FTP Published Blogs
[...] 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 [...]
Sasktel, Packing, Moving and Top Ten - LGR Webmaster Blog
[...] Process .html as PHP [...]
David Steadman
Thank you very much. You just saved me hours. The Server support person just told me I would have to change all files to .php
LGR
Glad it helped.