[Techtalk] directory handling with apache server

John Clarke johnc+linuxchix at kirriwa.net
Mon Oct 27 12:35:01 EST 2003


On Sun, Oct 26, 2003 at 06:57:53 -0500, Brenda Bell wrote:
> Quoting John Clarke <johnc+linuxchix at kirriwa.net>:
> 
> > you can give it a directory url without a trailing slash and it'll
> > still work.
> 
> Off-topic and totally unrelated to the poster's original question... but I

not at all.  it's directly related to the question :-)

> remember reading somewhere that the trailing slash is more of a browser
> (IE) optimization that anything else.  At least one recent version of IE

it's needed by the browser (any browser, not just ie) to allow relative
urls to work properly.

> handles http://example.com differently that http://example.com/ where the
> latter results in fewer round-trips.  I remember seeing the explanation
> somewhere, but it was such a bogus idea, I ignored it and forgot it.

it's not bogus, and i explained why in my previous post.  if you get a
directory url without the trailing slash, apache will send back a
permanent redirect to the url with a trailing slash.  the browser will
then fetch the new url.

this is what happens when i fetch a directory url without a trailing
slash:

    [johnc at dropbear ~]$ telnet kirriwa.net 80
    Trying 203.63.21.216...
    Connected to kirriwa.net.
    Escape character is '^]'.
    GET http://kirriwa.net/john HTTP/1.0

    HTTP/1.0 301 Moved Permanently
    Date: Sun, 26 Oct 2003 22:44:52 GMT
    Server: Apache
    Location: http://kirriwa.net/john/
    [snip]

note the status, 301 moved permanently, and the location, which is the
original url with a trailing slash added.  the status tells the browser
to try again, and the location tells it where to load from.  you'll also
see the new url appear in the browser's location bar.

this is all browser-independent - it works similarly in galeon, lynx,
mozilla, netscape, opera and ie.


cheers,

john
-- 
whois !JC774-AU at whois.aunic.net
GPG key id: 0xD59C360F
http://kirriwa.net/john/


More information about the Techtalk mailing list