HOW TO: .htaccess redirect to another server??

Discussion in 'Apache' started by datex, Dec 11, 2008.

  1. #1
    Can I do the below and how?

    I have a site located at one server (let’s say it has the domain name: domain.com). I have another domain name (let’s say it has the domain name: domain.co.uk) hosted at another server.

    I would like traffic to domain.co.uk to be redirected to domain.com but the browser must still says domain.co.uk. When you when click at a link at domain.com and it would now normally say domain.com/xyz.html the browser should say domain.co.uk/xyz.html
     
    datex, Dec 11, 2008 IP
  2. Lexiseek

    Lexiseek Banned

    Messages:
    2,499
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is the easiest thing in the whole world, as long as you have mod_rewrite.

    
    RewriteEngine On
    RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]
    
    Code (markup):
    Put that in the .htaccess on the old server you want to redirect. It will forward all traffic to the new pages on the new domain.
     
    Lexiseek, Dec 11, 2008 IP