.htaccess 301 Redirect: Moved Permanently


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

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) “”: 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. =]



  • do you know what happens to the old pages which are still in the cache of the SERP ? Do I have to wait until the next “dance” in order to have those pages disappear from the results ?

  • After you create this 301 redirect, the Search Engines will have to index the page again. Depending on how often you the SE Bots index your site (and which Search Engine), it should be removed from the search engine within 1-4 weeks.

    Google seems to update it’s index faster than Yahoo and some of the others.

  • hi, thanks for your advices!
    i really need to do a 301 for an old webpage directed to a new website..please help!

Leave a Reply

Your email address will not be published. Required fields are marked *