To slash or not to slash

Wednesday, April 21, 2010

That is the question we hear often. Onward to the answers! Historically, it's common for URLs with a trailing slash to indicate a directory, and those without a trailing slash to denote a file:

https://example.com/foo/ (with trailing slash, conventionally a directory)
https://example.com/foo (without trailing slash, conventionally a file)

But they certainly don't have to. Google treats each URL above separately (and equally) regardless of whether it's a file or a directory, or it contains a trailing slash or it doesn't contain a trailing slash.

Different content on slash and non-slash URLs is okay for Google, but often is less ideal for users

From a technical, search engine standpoint, it's certainly permissible for these two URL versions to contain different content. Your users, however, may find this configuration horribly confusing—just imagine if www.google.com/webmasters and www.google.com/webmasters/ produced two separate experiences.

For this reason, trailing slash and non-trailing slash URLs often serve the same content. The most common case is when a site is configured with a directory structure:

https://example.com/parent-directory/child-directory/

Your site's configuration and your options

You can do a quick check on your site to see if either of the URLs matching this pattern redirects to the other:

  1. https://example.com/foo/
    (with trailing slash)
  2. https://example.com/foo
    (no trailing slash)
  • If only one version can be returned (that is, the other redirects to it), that's great! This behavior is beneficial because it reduces