Trailing slash in URLs

Thomas Dowling tdowling at ohiolink.edu
Fri Sep 13 15:30:27 EDT 1996


> > I was perhaps thinking of the "canonical form" of URLs, but in any case
it is
> > clear that the trailing slash when accessing the root of a server is
not
> > required.  Thanks to Erik Jul of OCLC for pointing out my error...
> 
> Now I really wish I had asked this group about this before my site was 
> set up!  I should have included the trailing "/" in the URL in all our 
> site brochures, etc. because many local public libraries (my primary 
> audience) are using LYNX readers. (Often from inside their 
> Internet-connected OPACs.)
> 
> My non-technical understanding of this (and I'd love to know more about 
> exactly why this is..) is that LYNX looks for the "/" at the end of a 
> path name. Most servers are set up to read "jobsmart.org" as 
> "jobsmart.org/index.htm"  LYNX, apparently, cannot. It sees 
> "jobsmart.org" and says "can't find this file."


Having demonstrated, a couple months ago, that I didn't know the answer to
this, let me try to make amends.

AFAIK, no browser makes any intelligent guesses about the presence or
absence of a trailing slash; they simply pass it along as part of an HTTP
command to the server.

1. At the *server* end (meaning all the servers I'm able to test--NCSA,
Apache, IIS), an incoming request, with no trailing slash, for a file name
which exists as named, gets a successful HTTP code and the text of the
file.

2. An incoming request, WITH a trailing slash, for a directory name which
exists as named, gets a successful HTTP code, and either the text of the
default file within that directory if it exists, or a directory listing if
the server permits.  (The default file name varies from server to server;
NCSA HTTPd uses index.html, IIS uses DEFAULT.HTM, etc.)

3. An incoming request, with NO trailing slash, for a directory name, gets
an HTTP redirection code pointing at the same URL WITH a trailing slash. 
All browsers I'm aware of then automatically execute a second connection to
get the URL with the trailing slash.  

I cannot comment on the reported problem with lynx except to ask the
version in use.  My copy of Lynx 2.5FM has no problem retrieving
"http://jobsmart.org".

The semi-exception to number 3, as Peter Murray pointed out, is that you
can leave off the initial slash after the host name, which should indicate
document root, and still get the default document in document root, rather
than a redirection.



Thomas Dowling                    \ tdowling at ohiolink.edu
Asst. Director, Client/Server Apps.\    614/728-3600 x326
OhioLINK                            \    FAX 614/728-3610



More information about the Web4lib mailing list