Website Designers and Webmasters

Dedicated to all the tasks Webmasters, Website Developers and Website Designers find themselves facing.

.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 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. =]

Enjoy
Ashton

Tags: , , , ,

4 Comments »

  1. 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 ?
    thanks

    Comment by jmthomas — December 21, 2007 @ 6:23 am

  2. 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.

    Comment by Ashton Sanders — December 21, 2007 @ 12:55 pm

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

    Comment by El Mafufo — October 16, 2008 @ 9:12 pm

  4. Hi el mafufo,

    What trouble are you running into?

    Comment by Ashton Sanders — October 16, 2008 @ 9:40 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment