1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect entire site to single page on new site - with multiple exceptions

Discussion in 'Apache' started by Ian W, Sep 12, 2017.

  1. #1
    Hi all,
    I need to redirect all traffic from oldsite.com - including (almost) all subdirectories - to newsite.com, but with a small number of exceptions.
    I've added the script below to the root .htaccess file:

    Options -Multiviews
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/story [NC,OR]
    RewriteCond %{REQUEST_URI} !^/professions [NC,OR]
    RewriteCond %{REQUEST_URI} !^/offer [NC,OR]
    RewriteCond %{REQUEST_URI} !^/offer3 [NC,OR]
    RewriteCond %{REQUEST_URI} !^/faq [NC]
    RewriteRule ^(.*)$ http://newsite.com/ [R=301,L]

    On the whole this works, but only the /story exception works correctly. All the other listed exceptions redirect to newsite.com.

    Can anyone advise what I'm doing wrong?

    Many thanks,

    Ian
     
    Ian W, Sep 12, 2017 IP
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    Add '$1' at the end of the newsite.com
    http://newsite.com/$1
    Code (markup):
     
    RoseHosting, Sep 12, 2017 IP
  3. Ian W

    Ian W Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Many thanks for this - but doesn't adding the $1 mean that any subdomains specified in the original request will be carried over, so that oldsite.com/otherpage will try to go to newsite.com/otherpage?
    My original post may not have been particularly clear - aside from the exceptions, I want all traffic to go to the home page of newsite.com (effectively newsite.com/index.html), as the structures of the two sites are completely different.
     
    Ian W, Sep 13, 2017 IP