PDA

View Full Version : quick question


Jake
07-27-2002, 01:26 AM
I was wondering, is it the web server or the web browser that adds a trailing slash? Which adds the protocol (http)?

Example: http://www.example.com
turns into
http://www.example.com/

and

http://www.example.com/directory
turns into
http://www.example.com/directory/

My curiosity came from an ad on tv that had a web address like this:
example.com/directory

My guess would be the browser adds http:// and the server adds the trailing slash...but that's just a guess.

Thanks!

Syneryder
07-27-2002, 02:14 AM
Just guessing here, but I think it has to be the web server that adds the trailing slash, since it would be possible to have a file on the server named "directory". If the browser added the slash, it would potentially miss files like this - it must be up to the server to determine that the file is actually a directory, and hence the slash should be added.

Here's an example, try going to www.yourdomain.com/whatever where "whatever" is a non-existent directory. Notice that the browser doesn't add the slash to this, but if you replace the "whatever" with a real directory, the slash gets added.

PaulKroll
07-27-2002, 03:13 AM
In the case of http://www.example.com , there's really no slash to add: the browser makes a request to the root of the web server. So the browser "adds the slash".

However, for http://www.example.com/directory , that's a very different beast. In that case, the exact "object" is requested by the browser ("/directory" in this case) and the server comes back and tells the browser "Nope, that's a directory, make that '/directory/'" at which point, the browser sends another request with the trailing slash. So the server "adds the slash" on those.

This makes http://www.example.com/directory/ slightly faster than http://www.example.com/directory because there's no go-round while the server and browser work out that little detail. For internal links, you should certainly use the trailing slash whenever appropriate. But for non-web advertisements, it's just one more thing that people would forget anyway, so you might as well do the non-trailing-slash form.

Jake
07-27-2002, 02:55 PM
Thanks for the detailed answers, they're much appreciated.