I’ve already discussed how to create a 301 permanent redirect using PHP that allows you to forward one page to another. But what if you you have an entire site to redirect? What if you’ve changed domain names? There has got to be a better way to redirect your site besides, adding a php 301 redirect to every page. Well there is! It’s called .htaccess.
My next post will be a quick introduction to “.htaccess”.
If you only want to redirect from one page on your site to another, this is the .htaccess code to use:
redirect 301 /oldfolder/oldfile.htm http://www.websitesinaflash.com/new.htm
There are three parts to this redirect (make sure you put 1 space in between each element):
1) “redirect 301″: This declares that you are doing a redirect, and that the code is 301: Permanent Redirect.
2) “/oldfolder/oldfile.htm”: This declares the page you want to redirect from.
3) “http://www.websitesinaflash.com/new.htm”: This is where you want the page to redirect them to.
This is useful when you have renamed pages, and want to make sure google knows where your new pages are, and also any visitors that would be directed to that old page will automatically be directed to the new page.
But what about directing an entire folder or site to another folder or site?
You’ll have to wait for next post. =]