Redirect to new domain's homepage with 2 exceptions

Discussion in 'Apache' started by produceresults, Jan 6, 2011.

  1. #1
    Ok... I have been reading and banging my head against a wall for 2 days. I need assistance. Here is what I am trying to accomplish:

    We want to redirect customers to the new site's homepage no matter what page they are on with a few exceptions.

    Exception 1: We need to make sure the the /admin/ directory and ALL of its contents do NOT redirect

    Exception 2: There are 4 pages (/page.html, page2.html, etc) that we want to redirect to specific subpages and not to the homepage.

    I have 2/3rds of the equation but can't seem to get this all together. Here is what I have:

    
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^attitudes-gratitude-give-receive-every-your-life-p-364\.html$ http://beta.walkthetalk.com/attitudes-of-gratitude-how-to-give-and-receive-joy-every-day-of-your-life.html [R=301]
    RewriteRule ^tuesday-morning-coaching-p-566\.html$ http://beta.walkthetalk.com/tuesday-morning-coaching.html [R=301]
    RewriteRule ^change-good…you-first-p-260\.html$ http://beta.walkthetalk.com/change-is-goodyou-go-first.html [R=301]
    RewriteRule ^walk-talk-development-p-453\.html$ http://beta.walkthetalk.com/walk-the-talk-development-kit.html [R=301]
    RedirectMatch permanent /.* http://beta.walkthetalk.com/
    PHP:
    The part that is missing is the condition !^admin/$

    Can anyone help?

    Thanks,

    Scott
     
    produceresults, Jan 6, 2011 IP
  2. produceresults

    produceresults Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I wanted to update this post with my final result. I figured out how to accomplish this task so to anyone who wants to do the following here is the basic code.

    Redirect every page on one domain to new domain's homepage and excluding 1 or more directories as well as having a few pages redirect to specific subpages:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^old_page1\.html$ http://www.newdomain.com/old_page1.html [L]
    RewriteRule ^old_page2\.html$ http://www.newdomain.com/old_page2.html [L]
    RewriteRule ^old_page3\.html$ http://www.newdomain.com/old_page3.html [L]
    RewriteRule ^old_page4\.html$ http://www.newdomain.com/old_page4.html [L]
    RewriteRule ^admin - [L]
    RewriteRule ^blog - [L]
    RewriteRule ^images - [L]
    RewriteRule ^ http://www.newdomain.com/ [R=301]
    PHP:
     
    produceresults, Jan 7, 2011 IP