A trailing slash is a forward slash (“/”) at the end of a Url like domain.com/ or domain.com/page/. The trailing slash is generally used to distinguish a directory with the trailing slash from a file without the trailing slash. However, these are guidelines, not requirements.

In the past, a folder had a trailing slash and a file had no trailing slash. A folder indicates that there are more files and that you usually have an index file (index.html, index.php, etc.) to load the contents of the page from. For example, the content would come from domain.com/page/index.html, but domain.com/page/ would be displayed to users. For individual files you would have the file name and no trailing slash at the end.

In most systems these days, URLs do not point to files. The Url is a data set that is stored in a database. Serverless systems don’t even host files on your server.

Different Url Structures can be treated differently. Whether or not you opt for a trailing slash is more of a personal preference than anything else. Let’s look at some common scenarios.

Trailing slashes after the domain name do not matter

domain.com = domain.com/

These URLs are treated the same way and it doesn’t matter which version you are using.

Trailing slashes are important for other URLs

domain.com/page ≠ domain.com/page/

For each case except the trailing slash immediately after the root domain, a trailing slash is treated as a separate one Url.

Files should not end with a slash

In most cases, if you add a trailing slash to a file like .html, .php, .js, .css, .pdf, .jpg, etc., the file will not load. This is because most systems assume the file is a folder, and since there is nothing after that path, it usually returns a 404 page.

Now let’s look at the effects on SEO.

Trailing slashes and SEO

Depending on how your systems work, you may want to make different decisions. Here are some common scenarios.

The same content will be displayed on URLs with trailing slashes and non-trailing slashes

As mentioned earlier, if your content is displayed in both trailing-slash and non-trailing-slash versions of pages, the pages can be treated as separate URLs. The common concern here is that the content of the different versions will create duplicate content. In most cases, this shouldn’t be a problem as a canonical tag will likely indicate a preferred version. Even without this option, Google will usually pick a preferred version for you that will consolidate the signals. You can force the URLs to your preferred version if you want.

Whether or not you use a trailing slash, you want to make sure that all of the various canonical signals like redirects, sitemaps, internal links, canonical tags, etc., point to the version being indexed.

Different content is displayed on the URLs for trailing slashes and non-trailing slashes

In some cases, where two systems are using the same folder structure or specific A / B testing software, the version of a Url with and without the final slash shows completely different content. In these cases, you ideally want to choose one version to be indexed and displayed to users, and then redirect the other version to it.


Problems can arise with more complex setups with hreflang. Hreflang links should point to the indexed version of the pages. If a canonical tag refers to a version of the page with a trailing slash and Google indexes a page that way, but the hreflang tags refer to a version of the page without a trailing slash, those hreflang tags may not be honored.

Add or remove trailing slashes

This process changes depending on the system. It is best to check the relevant documentation before making any changes.


Remove slash:

RewriteRule ^ (. *) / $ / $ 1 [L,R=301]

Side note.

! -d searches for a directory and if one exists, the slash is not removed. If you don’t include this, these main directory pages may become corrupted.

Add a slash:

RewriteRule ^ (. *[^/]) $ / $ 1 / [L,R=301]

Side note.

! -f searches for a file, and if the file exists, the trailing slash is not added. This holds images, PDFs, JS, CSSetc. from breaking.


If you go to Settings> Permalinks, you can change whether you use a trailing slash when using a custom structure.

/% postname% / would add the trailing slash to urls

/% postname% would remove the trailing slash from URLs

JavaScript frameworks

Because of their routers, these systems may be a little different from what you are used to. You can either customize how the URLs work in the router, or if you don’t want to spend a lot of time on them, most of these systems have pre-built modules for adding or removing trailing slashes.

Subsequent effects on reporting

Reporting should be considered when deciding whether to use a trailing slash or not. For example, you can set up either a domain or a domain in the Google Search Console Url Prefix property. If you ignore the trailing slash when setting up a Url Prefix property (e.g. domain / folder), Google will add one anyway. As a result, all visits to domain.com/folder (without the trailing trash can) will not be reported because domain.com/folder/ (followed by a slash) has a higher tier.

Google Analytics (GA) has the same problem when trying to drill down content by folder when your main pages don’t have a slash. If both forward slashes and none of your URLs work, you might see both of them reported in GA.

You can add a filter as shown below to force trailing slashes on the URLs in your analytics reports if you want to consolidate the data.

Here is the regular expression: ^ (/[a-z0–9/_-]* *[^/]) $

Final thoughts

Changes always involve a risk. If your setup doesn’t cause problems, I wouldn’t try to force a change in your URLs. Technology has changed and the old one Url Slash conventions do not apply to most modern websites.