What would be the best way to automatically redirect to a mirror website if the main website being is down? Should it be done via DNS, and how can I set this up? Basically, what I need is to have an exact copy of the site (not frequently updated, so no synchronization necessary) to be a fall back incase of failure. Kind of almost like a load balanced solution.
Asked
Active
Viewed 3,569 times
2 Answers
1
What is your requirement? Changing DNS is possible, but due to DNS caching it could take up to 24 hours before the failover to your mirror is complete (i.e. everybody on the internet sees your mirror).
Do you need it to be automatic? Or is manually changing DNS records acceptable?
If you need instant failover without customers noticing downtime a solution with redundant hardware and load balancers is more appropriate (but also much more costly and complicated to maintain).

Martin Schapendonk
- 12,893
- 3
- 19
- 24
-
well, not quite ready to do it with the hardware option, so will do a simpler 302 for now. – ekaduki Nov 18 '10 at 12:39
-
Being able to send a 302 implies that the main website is not down, which is a contradiction with your question. – Martin Schapendonk Nov 18 '10 at 12:54
0
The codes for redirecting pages are 301 (permanent redirection) and 302 (temporary redirection). These codes are universal for all webservers, and that is where you should look to implement such changes.
Here's a very simple example using apache: about.com
Good Luck,
Yishai

Yishai Landau
- 620
- 4
- 14
-
i've looked it up. seems like it will work. i hope my shared hosting service supports modification of that! – ekaduki Nov 18 '10 at 12:39
-
Assuming the server is apache, look up .htaccess - this is a way to configure servers from the level of a single user, without needing administrator privileges. – Yishai Landau Nov 18 '10 at 12:41
-
If the main website is down, which server will send the 301/302? I don't think this answers the question. – Martin Schapendonk Nov 18 '10 at 12:55
-
the 302 response comes directly from the webserver upon page request. If the webserver is completely down, these settings won't help you, and you'll have to change the DNS (which takes time). If there are other issues, such as database not working, or that you're changing your code, the 302 reference is a good idea. – Yishai Landau Nov 18 '10 at 13:51
-
Think of it like phonecalls. You might want to send people directly to voicemail, or to your cellphone, but if the main operator is down - none of these settings will matter, and you will need to either wait for the operator to come back to life, or change operator – Yishai Landau Nov 18 '10 at 13:52