301 Redirect Site-wide Except Homepage

Discussion in 'Apache' started by tflight, Oct 21, 2005.

  1. #1
    Alright, I've tried every Google search I can think of, searched here, and made numerous attempts to figure out out myself... But it is Friday afternoon and my brain doesn't appear to be working.

    Anyway.... I'm trying to perform a site-wide 301 redirect to a new domain except for the homepage .

    So originaldomain.com/index.html stays the same while originaldomain.com/anythingelse gets 301 redirected to newdomain.com/anythingelse

    Any hints?
     
    tflight, Oct 21, 2005 IP
  2. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^\/index.html$
    RewriteCond %{REQUEST_URI} !^\/$
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
    Code (markup):
    will redirect everything except index.html and / to the new domain.

    cheers

    John
     
    johnt, Oct 24, 2005 IP
    tflight likes this.
  3. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Fabulous, worked perfect! Thanks a bunch!
     
    tflight, Oct 24, 2005 IP