Tuesday, January 18, 2011

Redirect website to a temporary domain

I'm in the process of moving an application from one web server to another. I have the current site on www.x.com.

I have already created www2.x.com and would like to set up a permanent redirect to www2.x.com to leave on the old domain until everyone's DNS has updated.

Note that I need to redirect pages across too, so /login needs to redirect properly etc etc.

What's the best way of doing this?

  • A simple rewrite on the old vhost should do the trick:

    RewriteRule ^(.*)$ http://www2.x.com$1 [L]
    
    From womble
  • I think you're asking how to redirect an entire site form one host to another. Note that the redirect won't work if DNS is not working right -- the remote browser will still do a DNS lookup for www2.x.com, so it has to exist and be properly served for this to work.

    To redirect all pages from one site to another:

    RewriteRule ^/(.*)$ http://www2.x.com/$1 [L,R]
    

0 comments:

Post a Comment