By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Trailing slashes in URLs

When Trailing slashes matters, and when they Dont. This article is about trailing slashes in URLs.

Edited: 2012-05-11 04:47

The Trailing slash is just as important as every other single character in URLs – http://brugbart.com/somepage/ is not the same as http://brugbart.com/somepage – but there are servers that incorrectly show the same content on both locations.

The only time when the trailing slash is superfluous, is when typing in URLs for your main domain – It doesn't matter if you type http://brugbart.com or http://brugbart.com/ – you will however find that many people claim otherwise, likely because they have not read much of the http protocol.

The trailing slash is always sent when a bare domain is requested – this is required by the HTTP specification. A request is sent to the host, along with a requested path. The path can not be empty, so a trailing slash is always included. The trailing slash can be said to represent the root of your domain.

What about directories?

Below would all be unique urls, but could easily hold the same content.

http://brugbart.com/
http://www.brugbart.com/
https://brugbart.com/
http://brugbart.com/index.html
http://brugbart.com/this-is-a-web-page/
http://brugbart.com/this-is-a-web-page

Webmasters should normally chose their Canonical URL carefully, to make sure that content is only available where intended, and won't generate duplicate content in the SERPs.

Another common concern, is around using the non slash version vs the slashed version when linking to bare domains – not including a slash at the end of your domain, will not do any harm. But the correct way to link, would be to include it. I.e.

<a href="http://brugbart.com/">Brugbart</a>

Doing it without the slash will however do no harm, as it will always be included automatically – it also wont make you lose linkjuice.

When http://brugbart.com/dir is requested, most webservers will first check to see if there is a file named dir – if that was not the case, they will then check if there is a directory named as such, and then do a redirect to http://brugbart.com/dir/ if a directory was found – otherwise it will simply throw out a normal 404 not found error.

Performance and Trailing slashes

Trailing slashes can have a slight performance impact depending on how the server is configured. If for example it has been configured to check for the existence of directories – where a requested page could not be found – there will be a slight delay due to the additional HTTP request if a directory is found.

See also

  1. How to Block or 404 out your Index
  2. Absolute and Relative Paths