[thelist] What is the Best Practice for Single Page Redirects?

Jeff Howden jeff at jeffhowden.com
Thu Jul 10 14:56:40 CDT 2003


ari,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Aredridel
>
> > <meta http-equiv="REFRESH"
> >       content="0;URL=url/goes/here/">
>
> The meta-refresh is good when you want the user to know
> they're being redirected, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

that depends on the timeout you have set.  if it's 0, they won't even see
the redirect.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> It should not be used with a timeout of zero, because it
> makes using the back button on the browser painful.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

that simply isn't true.  if there's a timeout of 0, the page with the
redirect is replaced in the browser history with the page being redirected
to.  it behaves identically to sending a 302 object moved header from the
server.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> The redirect method is better for most other things: a
> permanent-redirect code sent to a browser will allow,
> say, a browser, to automatically update bookmarks, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

if there were any browsers on the market that actually implemented that.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> By the way, the "proper" way to do a refresh is not with
> a meta tag, but the actual HTTP header:
>
>     HTTP/1.1 200 OK
>     Refresh: 5;URL=/foo/bar
>     ...
>
>     Content goes here
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

either way is "proper".

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Whereas a redirect should look like this:
>
>    HTTP/1.1 302 Temporarily Moved
>    Location: url-goes-here
>    ....
>
>    Content goes here
>
> and for a permanent move (as in a page having been moved to a new server
> or location)
>
>    HTTP/1.1 301 Permanently Moved
>    Location: url-goes-here
>    ...
>
>    Content here
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

be warned that many browsers don't correctly interpret a 301 status code.
even the search engines recommend that you use a 302 if for all redirects.

.jeff

——————————————————————————————————————————————————————
Jeff Howden - Web Application Specialist
Résumé - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/




More information about the thelist mailing list