Why Do URLs Often End With a Slash?

How Slashes at the End of URLs Speed Up Loading Times

Smart Tablet on Gray
Jeffrey Coolidge/Digital Vision/Getty Images

When you copy and paste a URL into your location bar, watch carefully to see if it changes. Many URLs are published without the trailing slash at the end of the domain, but when you visit the URL, the slash is added. Even though the URL in the link does not have the trailing slash, the slash appears in your browser window after you click.

The Basics of the Trailing Slash

Traditionally, URLs that pointed to files did not include the trailing slash, while URLs that pointed to directories did include the trailing slash.

This means that:

http://webdesign.about.com/example/ is a directory, while
http://webdesign.about.com/example is a file.

This distinction speeds up page loading because the trailing slash immediately tells the web server to go to that example directory and look for the index.html or other default file.

When you go to a URL without the trailing slash, the web server looks for a file with that name. If it doesn’t find a file with that name, then it looks for a directory and looks for the default file in that directory.

Leaving Off the Slash Results in a Redirect

When you leave off the slash on a URL that is pointing to a directory, you force the server to do a redirect. While it may seem instantaneous to you, it takes slightly longer for a page to load from a redirect than from the direct URL. And every little bit adds up.

Don’t Include the Slash After Filenames

The only time you shouldn’t include a slash is after a file name in the URL.

For example:

Type:
http://webdesign.about.com/example.html
Not:
http://webdesign.about.com/example.html/

If you add the slash, the web server looks for a directory named "example.html," and most servers do not then try to find a file name of that name. So your customers would get a 404 error in that situation.

Always Include the Slash When Linking to Your Domain With No File Name

You can speed up access to your home page by including the trailing slash on your domain name URL. For example:

http://webdesign.about.com/

While you can’t control what your readers type into their location bar for your URL, you can control what you link them to. Always include the trailing slash in your URL links. If you include it in your marketing materials as well, you can keep your pages loading quickly for your readers, as most people type whatever is printed without adding or removing characters.