Forum Moderators: open

Message Too Old, No Replies

HTML Permanent Redirect

         

chadmg

4:34 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



Is there a way to do a 301 permanent redirect using only html or client-side javascript? I have no access to server settings.

txbakers

4:38 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 301, 404 codes are all server generated.

If you want a particular page to redirect on loading, you can do it in javascript:

onLoad="location.href='newsite.htm'"

which will always take them to the new page.

DrDoc

4:48 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, onload won't trigger until the page has loaded...
It's probably a better idea to use a combination of a meta tag (with 0 second refresh time) or a JavaScript that is put at the top of the document, redirecting immediately, instead of waiting for the page to fully load.

chadmg

4:56 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



So there is no way to do a 301 redirect without server code? Meta redirects and javascript onloads are 302 redirects, correct?

It's ok anyways, since I just discovered Geocities allows php. :)

encyclo

5:11 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If Geocities allows PHP, then you're all set. As for other free hosting services, some of them allow
.asis
files, which allow you to add server headers such as a 301 redirect in the document. I believe Angelfire and Tripod.com both allow this method.

[httpd.apache.org...]

Of course, if you need to redirect a file with an .html extension or similar when using a free host, you are still forced to use a meta refresh or Javascript.

choster

5:24 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where we are forced to use an HTML redirect, we use a double-fallback:
first attempt is a JS redirect, then a meta-refresh call, then finally a link to follow manually. I didn't think they return any status codes other than 200 OK (or 304 Not Modified).

<html>
<head>
<title>Blue Widgets</title>
<script language="Javascript" type="text/javascript">
location.replace("/path/to/new/");
</script>
<meta http-equiv="refresh" content="0;url=/path/to/new/">
</head>
<body>
Continue to <a href="/path/to/new/">Blue Widgets</a>.
</body>
</html>