Redirect

Discussion in 'HTML' started by Per Jørgen Vigdal, Oct 29, 2005.

  1. 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.
    Per Jørgen Vigdal, Oct 29, 2005
    #1
    1. Advertising

  2. Per Jørgen Vigdal

    Stuart Guest

    Per Jørgen Vigdal wrote:
    > 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...

    --
    Stuart Brown <>
    http://www.edesign.cc
    Stuart, Oct 29, 2005
    #2
    1. Advertising

  3. Do you say that this can not be managed in html or dhtm





    "Stuart" <> wrote in message
    news:3BG8f.36657$...
    > Per Jørgen Vigdal wrote:
    >> 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...
    >
    > --
    > Stuart Brown <>
    > http://www.edesign.cc
    Per Jørgen Vigdal, Oct 29, 2005
    #3
  4. Per Jørgen Vigdal

    Stuart Guest

    Per Jørgen Vigdal wrote:
    > 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 :)

    --
    Stuart Brown <>
    http://www.edesign.cc
    Stuart, Oct 29, 2005
    #4
  5. Stuart wrote:

    > Per Jørgen Vigdal wrote:
    >> 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.


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


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Oct 29, 2005
    #5
  6. 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)
    Per Jørgen Vigdal, Oct 29, 2005
    #6
  7. Per Jørgen Vigdal

    Stuart Guest

    Per Jørgen Vigdal wrote:
    > 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.

    --
    Stuart Brown <>
    http://www.edesign.cc
    Stuart, Oct 29, 2005
    #7
  8. Per Jørgen Vigdal

    Stuart Guest

    David Dorward wrote:

    > 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.

    --
    Stuart Brown <>
    http://www.edesign.cc
    Stuart, Oct 29, 2005
    #8
  9. Per Jørgen Vigdal

    CyberDog Guest

    Per Jørgen Vigdal wrote:
    > 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



    Hm... how about something like this:

    ---snip---
    $web = "http://www.myoriginalsite.com";
    $backup = "http://www.mybackupsite.com";
    $var = @fsockopen($web, 80, $errno, $errstr, 2);
    if ($var) { header("Location: ". $web) } else { header("Location: ".
    $backup) }
    ---snip---
    CyberDog, Oct 29, 2005
    #9
  10. Per Jørgen Vigdal

    CyberDog Guest

    CyberDog wrote:
    > ---snip---
    > $web = "http://www.myoriginalsite.com";
    > $backup = "http://www.mybackupsite.com";
    > $var = @fsockopen($web, 80, $errno, $errstr, 2);
    > if ($var) { header("Location: ". $web) } else { header("Location: ".
    > $backup) }
    > ---snip---


    Sorry, forgot to mention, that would be the PHP sollution.
    CyberDog, Oct 29, 2005
    #10
  11. In article <YqI8f.19110$>,
    Stuart <> wrote:

    > Per Jørgen Vigdal wrote:
    > > 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).


    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.

    --
    Joel.
    Joel Shepherd, Oct 29, 2005
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    7,090
  2. bagsmode
    Replies:
    2
    Views:
    5,485
    bagsmode
    Jul 28, 2003
  3. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,230
    Srowe1975
    Oct 15, 2008
  4. Sal
    Replies:
    1
    Views:
    401
  5. Ron Howard
    Replies:
    2
    Views:
    514
    Ron Howard
    Aug 11, 2004
Loading...

Share This Page