If URL not exists then redirect to another URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vitamint
Forum Newbie
Posts: 1
Joined: Sat Aug 26, 2006 7:05 am

If URL not exists then redirect to another URL

Post by vitamint »

Hi,

i need a help to redirect my website.

i have hosted my site in 2 servers. form first server i just redirect the site to second server using php header code i.e.:

header("Location: http://www.mydomain.com/secondserver/index.php");

now sometimes my second server goes down. For this time period i want to locate the site to first server.

In my word i can say this way:

Task to do from first server
1. check if second server running or not. if running then redirect the page to second server.
2. if second server not running then locate the url to first server

please help!

thanks in advance
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Use the cURL extensions if you have can't retrieve urls using file_get_contents() . Can cache a working copy of a test page, then curl it and see if its changed or if it times out.
Post Reply