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

Redirecting domain and pages for a Re-brand

Discussion in 'Web Design' started by coolsheet, May 25, 2016.

  1. coolsheet

    coolsheet Jr. VIP Jr. VIP

    Joined:
    Mar 28, 2014
    Messages:
    356
    Likes Received:
    164
    Occupation:
    Being me
    Location:
    The Pleiades
    Hey guys. We're doing a complete re-brand and want to attempt to maintain our ranking. I've heard each page (old) needs to redirect to the new page that matches it.

    How should this be written in the htaccess? I have this code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
    RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
    </IfModule>

    But, some of the URLs don't match. I can see if all the URLs matched, how this would work. Is there a way to add more code to manually redirect each page that isn't matching? And is the code above correct for what I am attempting to accomplish???

    Thanks
     
  2. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    974
    Likes Received:
    680
    Occupation:
    Web/Bot Developer
    Add this to your htaccess file.

    Code:
    #rules for the individual redirections:
    RewriteRule http://olddomain.com/myUrl-1 http://www.newdomain.com/new-1 [R=301,L]
    RewriteRule http://olddomain.com/myUrl-4 http://www.newdomain.com/new-2 [R=301,L]
    RewriteRule http://olddomain.com/myUrl-3 http://www.newdomain.com/new-3 [R=301,L]
    #...and so on