Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Redirect

Reply
Thread Tools

Redirect

 
 
Per Jørgen Vigdal
Guest
Posts: n/a
 
      10-29-2005
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.


 
Reply With Quote
 
 
 
 
Stuart
Guest
Posts: n/a
 
      10-29-2005
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 <(E-Mail Removed)>
http://www.edesign.cc
 
Reply With Quote
 
 
 
 
Per Jørgen Vigdal
Guest
Posts: n/a
 
      10-29-2005
Do you say that this can not be managed in html or dhtm





"Stuart" <(E-Mail Removed)> wrote in message
news:3BG8f.36657$(E-Mail Removed)...
> 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 <(E-Mail Removed)>
> http://www.edesign.cc



 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      10-29-2005
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 <(E-Mail Removed)>
http://www.edesign.cc
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      10-29-2005
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
 
Reply With Quote
 
Per Jørgen Vigdal
Guest
Posts: n/a
 
      10-29-2005
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)


 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      10-29-2005
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 <(E-Mail Removed)>
http://www.edesign.cc
 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      10-29-2005
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 <(E-Mail Removed)>
http://www.edesign.cc
 
Reply With Quote
 
CyberDog
Guest
Posts: n/a
 
      10-29-2005
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---
 
Reply With Quote
 
CyberDog
Guest
Posts: n/a
 
      10-29-2005
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.redirect does not redirect from .aspx page =?Utf-8?B?VHJveQ==?= ASP .Net 3 10-15-2008 09:07 PM
Fix Google Tracking/redirect URLs, Proxo filter Splibbilla Firefox 2 07-23-2005 09:13 AM
Redirect to secure FTP site via response.redirect Ron Howard ASP General 2 08-11-2004 07:40 PM
Redirect LPT1 to COM4 for Bluetooth printing Bitman Wireless Networking 3 07-22-2004 06:19 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM



Advertisments