Trailing Slash: What Is It In a URL? And Should You Have It

This guide answers the question, “what is a trailing slash?”

Below, you’ll find examples of trailing slashes for URLs, an explanation of why it’s important for search engines, and a list of tips for setting up trailing slashes on a website. At the end of this page, you’ll also get tips on how to add or remove the trailing slash on a URL.

Consider this your ultimate quick guide to the trailing slash.

Trailing Slash

What Is a Trailing Slash?

A trailing slash is a forward slash (/) placed at the end of a URL. Trailing slashes are used to indicate a directory on a website as opposed to a file.

Examples of a Trailing Slash In a URL


Why Trailing Slashes Are Important

Trailing slashes are important because they distinguish a directory on a website from a file, which doesn’t have the trailing slash. However, not all websites follow this practice, and search engines like Google treat both URLs separately (or equally) regardless of whether it has the trailing slash or not.

From a technical SEO standpoint, a URL with a trailing slash may have the same content as a URL without the trailing slash. This is a common outcome with content management systems (CMS) like WordPress that redirect trailing and non-trailing slashes to the same web page for the user.

However, a trailing slash URL could have completely different content than a non-trailing slash web page. In that case, Google will index both URLs separately in the search engine for their own relevant search queries.

Should You Include a Trailing Slash In a URL?

You should use a trailing slash in a URL to denote a directory structure and to reduce duplicate content issues. A trailing slash also improves crawl efficiency for the website.

As for the root domain, the trailing slash doesn’t matter for indexing or SEO purposes. Both and will resolve to the same content. You cannot redirect a root URL using a trailing or non-trailing slash.

Trailing Slash Tips

The following list includes tips for using trailing slashes in the URL:

  • Trailing slashes at the end of URLs is the standard solution for website content.
  • Website owners should be consistent in their activities using trailing slashes. Do not mix and match directories with files using trailing slashes on URLs.
  • Be consistent with your preferred version.
  • Use the preferred version in internal links.
  • If both trailing slash and non-trailing slash versions contain the same content, then use a 301 redirect to resolve the preferred version for the user and search engines.
  • If a 301 redirect is not possible, then use a canonical link tag  (rel="canonical") on the duplicate page to point to the preferred version.

To learn more about SEO and trailing slashes, check out this related guide on trailing slash SEO.

Adding and Removing Trailing Slashes

Using WordPress

If you’re using WordPress for your website, then adding and removing trailing slashes is easy to do. Just follow these steps.

  • Go to Settings > Permalinks.
  • Click on “Post Name” to automatically add trailing slashes to URLs and set up a proper 301 redirect.
  • Another option is to choose “Custom Structure” and enter /%postname%/ into the field to add the trailing slash to URLs or /%postname% to remove the trailing slash from URLs.

Using .htaccess

The .htaccess file is a distributed server configuration file. If you have access to this file, then you can use the following rewrite conditions and rules to add or remove trailing slashes on your website.

Add trailing slash:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

Remove trailing slash:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ /$1 [L,R=301]

Using Canonical Link Tag

Another method for changing the trailing slash on a website is to use a canonical link tag. You can use this HTML element to indicate that a web page is a duplicate of another page by adding the <link> tag in the head section of the HTML code. The href link will point to the preferred version. In the example below, the canonical link is pointing to the directory with a trailing slash.

<link rel="canonical" href="" />

Note: If the web page has any alternate versions using the hreflang link tag then also make sure to you set up proper redirects or canonical links that are appropriate for the page. Below is an example for the canonical tag:

<link rel="alternate" href="" hreflang="en-us" />

Trailing Slash Summary

I hope you enjoyed this guide answering the question about what is a trailing slash.

As you discovered, a trailing slash is a forward slash (/) placed at the end of a URL. And trailing slashes are typically used to indicate a directory on a website as opposed to a file. However, modern CMS platforms and websites often have the same content on both the trailing and non-trailing versions of the URL. So it’s best to choose a preferred version and set up proper redirection for search engines like Google to crawl and index.

Supercharge your SEO with a FREE Mangools account! Find keywords, check backlinks, and more.