Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

we have a backup of our site www.site.com in another linux hosting. the backup is setup as wwwt.site.com from the cpanel. but there is no domain name assigned to it.we access the backup site by adding the ip address and hostname in the hosts file.

Now we want to display wwwt.site.com when a user types www.site.com for one hour without modifying the DNS.

How to redirect the request for www.site.com to wwwt.site.com ?

Note:we have another live website in the backup hosting ip address and there is no domain name pointing to the backup site

Hope somebody knows the answer

share|improve this question

migrated from stackoverflow.com Jan 8 '10 at 10:16

This question came from our site for professional and enthusiast programmers.

By "another linux hosting" do you mean that the site is on a completely different machine/location? –  Joel L Jan 8 '10 at 10:15

4 Answers 4

Use .htaccess instead to avoid the PHP overhead.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
share|improve this answer
Just a note that you should only use 301 (last line) if you intend this to be a permanent change. Otherwise you should use 307. –  Michael Mior Jan 8 '10 at 15:29

There is not really an automatic way of getting this to work, however, you could simply add a PHP script to www.site.com to redirect to wwwt.site.com

Something like this:

<?php header('Location:http://wwwt.site.com/'); ?>

share|improve this answer

Your question is a little unclear.


  • www.site.com and wwwt.site.com are on the same local machine.
  • www.site.com has a public ip address
  • wwwt.site.com does not have a public ip address but does have an entry in the /etc/hosts file on the local machine.
  • your web server is Apache.


  • temporarily serve wwwt.site.com from www.site.com

With the given assumptions, I would suggest using mod_proxy or mod_rewrite with the proxy extension.

Example 1:

Serve wwwt.site.com from www.site.com vhost using mod_proxy

<VirtualHost *:80>
    ServerName www.site.com

    ProxyRequests off
    <Proxy *>
        Order deny,allow
        Allow from all

    ProxyPass / http://wwwt.site.com/ retry=0
    ProxyPassReverse / http://wwwt.site.com/

Example 2:

Serve wwwt.site.com from www.site.com vhost using mod_rewrite

<VirtualHost *:80>
    ServerName www.site.com
    RewriteEngine on
    # The RewriteCond isn't necessary, but allows some flexibility.
    # If the file exists - redirect requests, otherwise do nothing.
    RewriteCond /var/www/redirect-reqs -f
    RewriteRule ^/(.*)$ http://wwwt.site.com/$1 [P]

Hope this helps.

share|improve this answer

agy, wwwt.site.com is in a different linux hosting server , all other assumptions are correct. the ip of this server currently host another website.so using http://ip will show that one

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.