URL with or without trailing slash – what’s the difference

  • by

You should know the difference lies in URLs with and without a trailing slash.

First: difference when the spider crawls

According to the link form, domain/abc represents the abc file in the root directory, and domain/abc/ refers to the default file in the abc directory. When the spider crawls domain.com/abc, the first step is to read the abc file in the root directory. After the abc file is not found, the default file in the abc directory under the root directory is automatically read; and when the spider crawls the domain. When com/abc/, the first is to directly read the default file in the directory under the abc directory in the root directory. In the case of the same resources, it can save the reading time, which is very necessary for SEO.

The URL is distinguished with and without a trailing slash because they are two different concepts. Without a slash, it is a web page; with a slash it is a directory.

Second: 301 redirect for a URL without a trailing slash

Kind of the same as the first difference. Just talk about it based on another aspect.

Quoted from https://blogs.msdn.microsoft.com/ie/:

When generating hyperlinks, always include a trailing slash if possible.  For instance, navigating to http://msdn.microsoft.com/ie takes one more roundtrip than http://msdn.microsoft.com/ie/.  When the browser navigates to the /ie url, the server merely sends down a 301 to the /ie/ url.  Both links work, but the second version is faster.

That is, when the browser resolve a URL like /ie, server will do a 301 redirect to a URL with a trailing slash like /ie/. Both URLs work but the second will be faster. Actually, you cannot feel the speed difference, and even might ignore it.

For a search engine, both URLs can be indexed. Note that, when you type a URL without a trailing slash and press Enter, the browser will add a slash automatically.

For traffic source, you can see both URLs, like http://m.facebook.com and http://m.facebook.com/ displayed in my blogger stats.

Conclusion: When exchanging friendship links or sending out links, it is necessary to have a trailing slash for a URL. Also necessary for SEO engineers.

Leave a Reply

Your email address will not be published. Required fields are marked *