View Full Version : How to do a redirect?
bellgamin
04-28-2001, 05:51 PM
A) Here's the deal...
1) For various reasons I have killed a fairly popular page on my site. Let's call that page's title "Deceased" and its file name dead.html.
2) When folks try to visit dead.html, I want to automatically redirect them to (let's call it) alive.html
3)Okay, so let's call my site... site.org. Here's some code I THINK will work, but will it? Is there a better (EASY!) way? Is there some way to notify visitors that they are being redirected, so I don't piss them off? The code...
<html> <head> <title>Deceased</title>
<meta http-equiv="refresh" content="1, url=http://www.site.org/alive.html">
</head> <body> </body> </html>
Yeah,I know there are ways to avoid the redirect altogether but, for various reasons, I MUST redirect.
By the way, I pieced the above code together from an HTML manual that is greek to me. I do my site with a wysiwyg & haven't bothered to learn html.
Any suggestions would be magnificent!
Aloha,
Bellgamin
That code will do the job :D.[nbsp][nbsp]Pat yourself on the back.[nbsp][nbsp]Some people have old browsers so you should put in the body
"in case you aren't automatically taken to the new page click here" with the click here being a clickable link.
If your do it for you editor won't let you edit[nbsp][nbsp]raw HTML just open note pad, put the code in there and "save as" deadfilename.html (or whatever file extension it is)
I have no advice on how to get your do it for you editor to do this for you.[nbsp][nbsp]I don' know how to use them LOL.
In case you have to use note pad the code for a link would be (and it goes in between the body tags)
"In case your browser doesn't bring you to the new url, <A HREF="live.html">click here.</A>"
Keller
04-29-2001, 06:39 AM
Using a little javascript makes the redirect a little nicer, and won't leave "dead.html" in the browser history, so the BACK button doesn't go back to it.
<html>
<head>
<title>Deceased</title>
</head>
<script language="JavaScript1.1">
<!--
location.replace("http://www.site.org/alive.html");
//-->
</script>
<noscript>
<meta http-equiv="refresh" content="0; url=http://www.site.org/alive.html">
</noscript>
</head>
<body>
In case your browser doesn't bring you to the new url, <a href="live.html">click here.</a>"
</BODY>
</HTML>
bellgamin
04-30-2001, 02:52 AM
Wow! Thanks to both of you. FQ in general, and you two kind folks in particular -- just the grrrreatest!
I used the simple html for now and, voila! It works.
About the java -- I'm eager to use the routine you suggested
(as much from wanting to learn as from anything else.) But I have a question: Are there going to be very many folks whose browsers won't be able to execute java script?
May God bless you both for taking the time & trouble to help a neophyte. His blessings on thee & thine.
Mahalo and aloha,
Bellgamin
Justin
04-30-2001, 03:47 AM
Are there going to be very many folks whose browsers won't be able to execute java script? These days, no. Anyone who disables JavaScript does so knowing that msot sites out there today simply won't work, and they're usually prepared to deal with such situations.
I used to try and code for 3.x browsers, but these days, if they can't do simple JavaScript, CSS, or whatever, then I'm not going to worry about it, they have to be used to 99% of the web being broken by now... There comes a time when one must upgrade...
In short -- a simple JavaScript redirect should be fine, but it's good to include some text and show it for a second. Not so much for old browsers, but more so that the user is aware as to why they are being redirected. I hate when I'm redirected instantly (with the tell-tale "Click-Click" sound in IE 5.x) not knowing why...
------------------
Justin Nelson
SFE Software (http://www.sfesoftware.com)
Keller
04-30-2001, 06:51 AM
The javascript is preety safe to use - even if the user set javascript off it should still do the META refresh.[nbsp][nbsp]There might be some problem with Opera (older versions, I think).[nbsp][nbsp]Well, they count for about 1% of the market, so not much worry.
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.