Skip to content

The address answers with and without its last slash

url-slash-duplicateminor
On this page

Why it matters

  • /contact and /contact/ are two different addresses to Google, however alike they look. When both answer the same page, they compete with each other: links, and what search engines learn of the page, are split between them.
  • Google asks a site to choose one address for a page: a permanent redirect from the other, or a rel="canonical" on both naming the chosen one.
  • Google often folds such a pair by itself, but then it chooses, not you, and crawls the page twice.

How to fix

Choose one form, with the slash or without, and send the other to it with a permanent redirect:

nginx
# nginx: addresses without a slash at the end go to the same address with one.
rewrite ^([^.?]*[^/])$ $1/ permanent;
  • Apache (mod_rewrite): RewriteCond %{REQUEST_FILENAME} !-f then RewriteRule ^(.*[^/])$ /$1/ [R=301,L].
  • On a platform whose server you cannot change, give both forms the same <link rel="canonical">, naming the chosen one.
  • Link to the chosen form everywhere on the site, the menus and the sitemap included.

How we detect

  1. For a page that answered 200 with HTML, we ask once for the same address with the slash at the end of its path toggled, as ArablyzerBot, without following a redirect, where robots.txt lets us. The site's root, and an address that ends in a file's name (/page.html), have no other form and are not asked.
  2. The rule fails when that address answers 200 with the same page, the same title and nine tenths of the same text either way, and neither names the other as its canonical, nor do both name the same one.
  3. A redirect between the two, an error, or another page passes.