Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using HTML to redierct to Secondary URl if....

Status
Not open for further replies.

paul172

Technical User
Feb 20, 2003
117
GB
Hi,

Hope this isn't too much of a stupid question, but I'll ask it anyway. The reason for asking is too long and involved to go into here, so I won't...;)

I have created a small VB app that checks to see if URL1 is up and valid, if not it directs users to URL2. This works well, but just wondered if I could do the same with HTML code as it would be easier to deploy to users PC's.

Thanks,
Paul
 
you might be able to accomplish this though an ErrorDocument in your .htaccess or even maybe a mod_rewrite (RewriteRule). depends on how you would know through the url.

if you can work it this way, you can avoid scripting, but your purposes may not be able to use this.
 
I think there would ba a javscript solution in trying to get response to a HTTP HEAD request of the URL in question and then if not redirect to the alternative URL.

You might get some code for this in a forum related to AJAX or Web 2.0 techniques. It's quite common to make requests from javascript instead of requesting a whole new page.

A simple and classic server side approach is to have error pages, like progman1010 said. In the normal case you define one error page for each server error, like famous 404 File not found error. A good hoster will let you customize these error pages.

Bye, Olaf.
 
And if the reason for that question is, you have reorganized the structure of your website and want old links to still work, you'd still keep simple html, php or whatever pages that simply redirect to the new URL.

You can do html redirects, if it's html URLs, if it's php URLs the simplest redirect the user won't even see a blank html page while being redirected is to send a redirect header back.

Code:
<?php
header("Location: [URL unfurl="true"]http://www.example.com/");[/URL] /* Redirect browser */
exit;
?>

Code:
<http...>
<head>
<meta http-equiv="refresh" content="0;url=http://www.example.com/' />
</head>
</http>

So what you do in this case is actually make the old URL valid again by putting the expected file on the server, but only let this URL redirect to the new one.

Bye, Olaf.
 
Hi,

Thanks for all the suggestions. The reason I was asking the question was, we are implementing a fall over solution(Neverfail), which would work well if we controlled the DNS entries directly for our URL, but we don't.

Thanks,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top