1. Technology

Why do URLs often end with a slash?


Smart Tablet on Gray
Jeffrey Coolidge/Digital Vision/Getty Images
Question: Why do URLs often end with a slash?

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. For example, click on this link to my home page. The URL in the link does not have the trailing slash, but the slash will appear in your browser window after you click.


Traditionally, URLs that pointed to files did not include the trailing slash, while URLs that pointed to directories do 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 helps speed 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 – Redirects Slow Down Web Pages

When you leave off the slash on a URL that is pointing to a directory, you are forcing the server to do a redirect. While it may seem instantaneous to you, it does take 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:


If you add the slash, the web server will look 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:


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 help keep your pages loading quickly for your readers, as most people type whatever is printed without adding or removing characters.

  1. About.com
  2. Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. Beginning HTML Tutorials
  6. URLs Ending With a Slash (Why It's Important)

©2014 About.com. All rights reserved.