1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

301 redirect of an entire site

Discussion in 'White Hat SEO' started by charlesbrunkle, Apr 16, 2010.

Tags:
  1. charlesbrunkle

    charlesbrunkle Registered Member

    Joined:
    Dec 11, 2009
    Messages:
    89
    Likes Received:
    25
    Hi

    I have an old site old-site.com and I did a 301 redirect to new-site.com using this code:

    Code:
    redirect 301 / http://www.new-site.com/
    but it only works with the homepage, if I go to old-site.com/test.html it wont redirect me to new-site.com....

    Do I need to add anything else to the .htaccess file?

    Cheers
     
  2. jimbo2087

    jimbo2087 Regular Member

    Joined:
    Jan 24, 2010
    Messages:
    205
    Likes Received:
    149
    Location:
    UK
    Use this code. obviously replace the url with your new site:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://thesiteyouwanttoredirectto.com/$1 [R=301,L]
    Any page you go to on your old site will automatically redirect to the new site super fast.

    More info on other ways to do a 301 - http://www.webconfs.com/how-to-redirect-a-webpage.php
     
  3. loopline

    loopline Jr. VIP Jr. VIP

    Joined:
    Jan 25, 2009
    Messages:
    3,371
    Likes Received:
    1,799
    Gender:
    Male
    Home Page:
    Using Jimbos method is best if you have modrewrite enabled. Elsewise with your method you have to create a 301 entry in your .htaccess for each and every page.
     
  4. geteasymoneynow

    geteasymoneynow Regular Member

    Joined:
    Jan 17, 2010
    Messages:
    336
    Likes Received:
    290
    Occupation:
    Any Thing
    Location:
    With your girlfriend
    or you can use cpanel and do a permanent redirect
     
  5. jimbo2087

    jimbo2087 Regular Member

    Joined:
    Jan 24, 2010
    Messages:
    205
    Likes Received:
    149
    Location:
    UK
    If you are using something like wordpress you could also probably use a php redirect in the header as long as it appears on everypage.
     
  6. rocket

    rocket Regular Member

    Joined:
    Apr 14, 2009
    Messages:
    471
    Likes Received:
    131
    Occupation:
    Web developer and marketer
    Location:
    In my competitor's mind
    yep. Jimbo's method is what i've been using for a long time now. good job Jimbo.

    here's the php version just in case anyone needs it:

    Code:
    
    
    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.new-url.com" );
    ?>
     
    Last edited: Apr 17, 2010
  7. aftershock2020

    aftershock2020 Senior Member

    Joined:
    Oct 19, 2007
    Messages:
    981
    Likes Received:
    477
    Even though that works, it is better to directly create a new php redirect page for each of your individual pages rather than using any error redirect at all, as it still logs in with the SE as an ' error ' issue on the page and if it links, it will tear down your ranking over time, as well as block your visitors from seeing your page if they have their browser settings high enough not to display any pages with errors in them, for security.