301 redirecting

Discussion in 'Web Design and Development' started by phadam, Oct 17, 2010.

  1. phadam macrumors regular

    Joined:
    Jan 21, 2009
    #1
    Looking to redirect my site over to a new more appropriate domain name. Found some great reading on the web about 301 redirects which will be pretty helpful when it comes time to start the work. However, was wondering if anyone has had any prior experiences with the redirecting and any troubles they may have come across or things to look out for and expect through the process. This will be my first attempt and would ideally love for this to go as smoothly as possible. Thanks!
     
  2. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #2
    PHP:
    <?php
    $url 
    $_SERVER['REQUEST_URI'];
    Header("HTTP/1.1 301 Moved Permanently"); 
    Header("Location: http://www.mysite.com" $url); 
    This will redirect the user to the exact page they were wanting to go to on your old site to your new site.

    For example
    www.myoldsite.com/about to www.mynewsite.com/about


    Or you can use the following to redirect all requests to your index page.
    PHP:
    <?php
    Header
    ("HTTP/1.1 301 Moved Permanently"); 
    Header("Location: http://www.mysite.com"); 

    I used the first method and it worked perfectly for the site in question. Its google rank moved within a week and the new domain was at the top of the google page for all of the search terms that the old site was.
     
  3. manueld macrumors 6502

    Joined:
    Jun 8, 2009
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    I've got a number of 301 redirects in my .htaccess file. I like them. It just takes a bit of geek to get them working sometimes for fanciful stuff, but a simply domain redirect is easy.
     
  5. phadam thread starter macrumors regular

    Joined:
    Jan 21, 2009
    #5
    great so far. thanks! what about email. i haven't looked into this yet but what's the process involved on getting old email redirected to the new email. Any real complications there as opposed to just a domain redirect?
     

Share This Page