Okay I need to change my website from html to php im not changing the individual files only renaming them to php in order to use tracking for affliates. But I want to know what is the easiest way to 301 redirect without losing my rankings? Obviously I have backlinks that point to example.htm and they will now be example.php. Another question will i have to manually change all my html code to reflect php within all my pages?
To accomplish the site wide 301 redirects from *.html to *.php simply create a .htaccess file in the root folder of your web with the following directives in it: As far as whether you need to manually change all of your HTML code to link to .php instead of .html, you don't HAVE to do so... But I would recommend it. The 301 redirects will take care of redirecting to the .php (even for your internal links). But rumor has it that each 301 redirect dimishes slightly the amount of "link juice" or page rank passed out on the outbound links. Some estimate between 1% and 10% but who the hell really knows. So it's a good idea to clean up your code at some point to eliminate the unnecessary redirects for links you have control over. I would suggest not renaming you .html files to .php. Instead I would copy *.html to *.php in ever folder of your web. Doing so will buy you time to edit all of the links to the old .html pages in the .php files while your site is still running as .html. Once you've changed all of your .html links in the .php files to .php links then put the .htaccess file in the root to start redirecting... Whether a user or a crawler on your site at the time of the switchover requests a .html URL OR a .php they will find the page they are looking for. There won't be any period where people are getting 404 errors. This will also make it easy to revert back to .html if you run into problems. To revert back simply rename or remove the .htaccess from the root so the redirects no longer occur. Then at some later time when you know that life is good and ALL pages on the site are being successfully redirected properly from .html to .php, you can rename or remove all of the .html files. Enjoy! NOTE: You may see a dip in your rankings for a period of time. You have to wait for the engines to recrawl every inbound link to your site, discover the 301 for that particular inbound link, and give the .php URL credit for that particular inbound link to the old .html file. So depending on how many inbound links you have and how often the various sites that link to you get crawled, you might see a drop in traffic for a few days or few weeks. But don't be alarmed... it's simply the process you have to go through... Things will bounce back as they recrawl more and more of your inbound links and discover the 301s.
Thanks for the reply, so in the long run after adding that line to htaccess i should manually change all code from html to php and also renaming the files from .htm to .php and then it should be finished?
Place the code below in an .htaccess file in your root directory. Then the .html files will be parsed the same as php and you will not have to change to the .php extension as php coding will now work in those .html files AddType application/x-httpd-php .html I would in your case do some more research including ask your host for the specific code that will accomplish this on their servers. There may be a small change needed, they will let you know. If this does not apply to your circumstance, well, I was trying to be helpful. ###