[geeks] Re: Apache

Jonathan C. Patschke jp at celestrion.net
Fri Apr 12 09:07:54 CDT 2002


On Fri, 12 Apr 2002, [iso-8859-1] Bertrand HUTIN wrote:

> redirecting:
> <meta http-equiv="refresh" content="0; URL=nojava.html"> 

Bad, bad, bad, bad, bad, bad, BAD!  This is -never- -ever- the right way
to do a redirect.  It makes the back button absolutely useless (and
downright annoying, should you -try- to back up), pops a worthless entry
into the history, and is just generally annoying.  Meta tags should die.

> other ways use Java:
> <script language="JavaScript">
>                    <!-- redirects to a page for JavaScript 1.0
>                      window.location.href = "js0.html"
>                    //-->
>                    </script>

Well, that's not as annoying, but I browse whe Javascript[1] off.

Why not do redirection the Right Way, since you're building a CGI anyway:

echo Location: /users/$REMOTE_USER/
echo Content-Type: text/html
echo ""
echo '<html>'
echo '  <head><title>Object Moved</title></head>'
echo '  <body>'
echo '    Sorry, it's over <a href="/users/'$REMOTE_USER'/">over'
echo '    here</a>.'
echo '  </body>'
echo '</html>'

This will cause the HTTP server to send the correct "302 Object Moved"
response, instead of "200 OK" response, which will cause the browser to
silently request the new page, without displaying anything first, and
without popping a useless page from hell in the history.  This is, in
fact, exactly what happens when you request
"http://www.example.org/users/foo" instead of
"http://www.example.org/users/foo/".

Sorry for sounding like an ass, but improper redirects and pages that
defeat my back button or require Javascript to do absolutely -nothing-
that can't be done in HTTP are all pet-peeves of mine.  Especially since
that meta-refresh hack crashes Netscape on IRIX, should you try to back
over the page.

--Jonathan
[1] Which is nothing at all like Java.  The two have -nothing- in common
    except the first four letters of their names.



More information about the geeks mailing list