Is there consistency and/or a standard on how browsers send a url to a host related to trailing slashes?
Meaning, if I type in http://example.com
in the address bar of a web browser, is the browser suppose to add a trailing slash (http://example.com/
) or not?
As far as the protocol is concerned,
http://example.com/something
andhttp://example.com/something/
are quite different. Some servers might redirect you from one to the other if it is implemented in such a way.As for the pure domain names, it always sends a request ending with a slash. (The domain name itself is not included in the path section of an HTTP request, just as Greg Hewgill and the others wrote. It is, however, included in the headers.)
You can check it with a tool like Fiddler or WireShark.
The HTTP request sent from the browser to the server does not include the domain name, only the "path" portion (starting from the first slash after the domain name). Since the path cannot be empty, a
/
is sent in that case.A sample GET request for the root of a web site might be:
The
/
above cannot be omitted.As RFC 2616 tells:
Read more: http://www.faqs.org/rfcs/rfc2616.html#ixzz0kGbpjYWa
Read more: http://www.faqs.org/rfcs/rfc2616.html#ixzz0kGcaRbqU
Note that it's a very different matter when the URL has a path element:
is a different URL than
and could in fact contain different content, and have a different search engine ranking.