HTML to PHP
Turn your .html and .htm pages into PHP pages without changing the extention on the Apache Web Server.
Problem: Your site is indexed in Google and has lots of .htm or .html pages that are well indexed and have links pointing to them. You would like to serve dynamic content (news, ads, blogs etc.) while keeping your page extentions intact.
Here are the easy steps required to tell Apache to interpret your .html files as php files:
Edit the .htaccess File :
To process .html pages with PHP add the line:
AddType application/x-httpd.php .html
To process both .html and .htm pages with PHP add the line:
AddType application/x-httpd.php .html .htm
This implementation should work on most servers, but some might require the extra line:
AddHandler x-httpd.php .html
Some Servers require:
addtype application/x-httpd-php .html
AddHandler x-httpd-php .html
Notice the httpd-php instead of the httpd.php
Testing your page:
Enter the following code somewhere into the <body> of your .html page:
<?php echo 'Hello PHP World!'; ?>
If you open the page in a browser and it displays <?php echo 'Hello PHP World!'; ?> in the page it didn't parse the page correctly. If it only displays Hello PHP World! it parsed the page correctly.