Redirect

P

Per Jørgen Vigdal

I need to redirect to an alternative url if an other redirect fails.

Here is the logic



If( redirect("URL_A") != success )

redirect("URL_B")





In other words:

If the server that host the URL_A that I am trying to redirecting to is
down, I want to redirect to an other server that host URL_B





Thanks for your help.
 
S

Stuart

Per said:
I need to redirect to an alternative url if an other redirect fails.

Here is the logic



If( redirect("URL_A") != success )

redirect("URL_B")


Redirects don't work quite like that - they don't tend to 'look before
they leap', so to speak.

You'd have to devise some method of checking the server was up (In PHP,
you could attempt to call fopen() on a resource on that server, and call
a redirect based on the result.)

Depends on your server configuration & language of choice, of course...
 
S

Stuart

Per said:
Do you say that this can not be managed in html or dhtm

You could do it using Javascript and MSXML (AJAX). But this is probably
overkill, and wouldn't work in anything but the latest browsers with
JavaScript switched on.

Why not just have a plain old hypertext link on the originating page
that says 'Mirror', 'Alternate Server' or similar? It saves unnecessary
fuss, and will work in pretty much anything :)
 
D

David Dorward

Stuart said:
You could do it using Javascript and MSXML (AJAX). But this is probably
overkill, and wouldn't work in anything but the latest browsers with
JavaScript switched on.

Since it involves checking if a server if up, I doubt this is possible (due
to cross domain scripting security issues).
 
P

Per Jørgen Vigdal

A plain old hypertext does not solve my problem.

Because I do not think it is a good solution to

ask the user to hit one link(URL_A), and explain that if it does not work

Go back and hit another.( URL_B)
 
S

Stuart

Per said:
A plain old hypertext does not solve my problem.

Because I do not think it is a good solution to

ask the user to hit one link(URL_A), and explain that if it does not work

Go back and hit another.( URL_B)

True, but the only other viable way is to use server-side scripting
(PHP, ASP etc).

HTML alone doesn't have the capacity to do what you require.
 
S

Stuart

David said:
Since it involves checking if a server if up, I doubt this is possible (due
to cross domain scripting security issues).

Ah, good point - it's probably possible on Windows with IE prior to XP
SP2, but little else.
 
J

Joel Shepherd

Stuart said:
True, but the only other viable way is to use server-side scripting
(PHP, ASP etc).

No: there are server-side hardware solutions as well. Setting up a
hardware load-balancer with a virtual IP address over a pool of
webservers will generally assure that clients are directed to 'live'
webservers. (Of course if a live webserver goes down in the middle of
handling a request, that request is out of luck, but ...).

<http://www.cisco.com/univercd/cc/td/doc/product/iaabu/localdir/ld31rns/l
dicgd/ld3_ch1.htm>

Sound like overkill? For the vast majority of sites it is. For most of
us mortals, having the webserver go down for a little while is an
annoyance, but not worth a significant investment in network hardware to
avoid. But if the OP is looking to do it right, a hardware load-balancer
is the most reliable way of assuring that requests get routed to a live
server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top