Moving from HTML to PHP
This is a problem that many webmasters are ought to deal with sooner or later. Especially those, who have old sites, which were all based on .html files. Of course one can just change all .html extensions to .php and replace the same characters in pages’ code. However, if you deal with SEO and your old good site occupies good position in SERPs, such changes can be fatal for your project for the following reasons:
1. All indexed .html files must be indexed again with .php extensions.
2. All links pointing particular page will be lost, unless you report all of your link partners and site owners, who link to you (re-indexing of new links will take some time too).
3. You will lose a lot of
traffic from search engines during re-indexing of the whole site will occur, even if you put an error page that will redirect surfers somewhere to your .php pages.
4. Nobody knows whether your site will return back to good positions in SERPs after it will drop out.
So, what to do if you don’t want to change file extensions for the purpose of SEO, but need to include some php code in your pages anyway? There are several methods.
The first, and the most obvious is to use mod_rewrite (in case if your server supports mod_rewrite and you have permissions to modify .htaccess file). If yes - put the following strings in your .htaccess file:
RewriteEngine on
RewriteRule ^(.*)\.html $1\.php
Now all requested .html pages will be automatically substituted with .php pages.
Another method works with .htaccess again. Add the following string to .htaccess file:
AddHandler application/x-httpd-php .php .html .htm
I think that this method is the most convenient one, because it simply allows executing PHP scripts to run in .html files. If you have no access to your .htaccess file, contact your hoster and request to make appropriate modification of httpd.conf for your site.
If you were using SSI on your site, for instance like this:
Than you can replace it with the following string in your .php files:
< ? include('file.txt'); ?>
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Excellent article. I think many designers are going to have to migrate over from HTML to PHP and not enough of them know the benefits of .htaccess files. I have recently added that file to my own sites in an effort to avoid duplicate content.