Redirect [whatever1].domain1.com/[whatever2] to [whatever1].domain2.com/[whatever2]

Discussion in 'Apache' started by evert, Sep 20, 2011.

  1. #1
    Hi all,

    We have a customer here, with a shedload of subsites on [whatever].domain1.com. They now have a newer/different/shorter domain which they prefer to use: domain2. Is there an easy way to have Apache send all requests that come in on [whatever1].domain1.com/[whatever2] to [whatever1].domain2.com/[whatever2] with either a 301 or a 302 (hasn't been decided yet).


    greetings,
    Evert
     
    evert, Sep 20, 2011 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    Give this one a shot, Evert:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^whatever1.domain.com$
    RewriteRule ^(.*)$ http://whatever1.domain2.com$1 [R=301,L]
    Code (markup):
     
    zacharooni, Sep 21, 2011 IP
  3. evert

    evert Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    Will that redirect to http://[whatever1].domain2.com/? or to http://whatever1.domain2.com/ ?
    (it should go to http://[whatever1].domain2.com/ )


    greetings,
    Evert
     
    evert, Sep 21, 2011 IP
  4. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #4
    zacharooni, Sep 21, 2011 IP