The slash at the end, capital letters and index.html: one page at several addresses

SEO & Marketing·· 54 views· 4 min read

The short answer: to a browser and to Google, /contact, /contact/, /Contact and /contact/index.html are four different addresses. On the server they may open the same page, give a 404 or redirect, depending on whether the path is a real folder, a real file or an address built by an application such as WordPress. If more than one answers 200, you have duplicate pages; if one gives a 404, somebody’s link is broken. The domain name does not care about capitals; the path, on a Linux server, does.

The variants, and what usually happens

Variant What usually happens What you want
A real folder without the slash: /gallery The server answers 301 to /gallery/ (Apache and LiteSpeed do this for folders). Fine. Link to the version with the slash and save a hop.
A WordPress page with or without the slash WordPress redirects to the form its permalink structure uses. Fine. Internal links in that same form.
Capitals: /Contact On a Linux server it is another file: a 404, or two copies if both exist. Lower case always. Redirect the capitalised addresses already out there.
The index file: /index.html, /index.php Opens the home page again, at a second address. 301 to / and never link to index.html.
Double slash: /shop//shoes Often opens the same page. Fix the template or code that builds the link (a base address ending in “/” joined to a path starting with “/”).
Domain in capitals: WWW.yourcompany.com Same address: the browser lower-cases the name. Nothing to do.

Choosing one form and enforcing it

1 Test each variant in a terminal with curl -I https://yourcompany.com/contact, then the same with the slash, with capitals and with index.html. Two variants answering 200 are duplicates; a 301 to the right form is fine; a 404 on a variant people use is a broken link.
2 Pick the form your platform already uses: in WordPress, the permalink structure decides; on a site made of files, folders take the slash and files do not. Do not try to force the opposite.
3 Use that form everywhere: menus, internal links, sitemap and canonical tag. See internal links and the canonical tag.
4 Send index.html and index.php to the folder. Take a copy of the .htaccess and add, above other rewrite rules: RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\s/+(.*/)?index\.(html|php)[\s?] [NC]
RewriteRule ^(.*/)?index\.(html|php)$ /$1 [R=301,L]
The condition on the original request stops the rule from looping with the index file the server itself serves. Test in a private window.
5 Capitals: lower-casing everything automatically needs server-level configuration, which cannot be done in a .htaccess. On shared hosting, fix the links and redirect, one by one, the capitalised addresses already shared, with lines such as Redirect 301 /Contact /contact (this kind of rule is case-sensitive).
6 Check Search Console for the duplicate-page and redirect statuses: crawl errors in Search Console.
Do not add a rule that adds or strips the slash on top of what WordPress already does. Two rules that disagree (one strips the slash, the other adds it) make an endless loop: ERR_TOO_MANY_REDIRECTS. And test any new .htaccess rule with a 302 first, because the browser remembers a wrong 301.
File and folder names in lower case from day one avoid half of these problems. Anyone bringing a site from a Windows server, where capitals do not matter, meets this surprise first: moving a site between Linux and Windows.

Not sure which form of the address your site should use, or did the rule cause a loop? Send us the domain and two variants that behave differently.

Open a support ticket

SEE ALSO

The canonical tag: duplicate pages, www or not, and which address Google keeps

What a good page URL looks like, and how to change a bad one safely

301 redirects when you change a page or a domain

ERR_TOO_MANY_REDIRECTS: when the site redirects in a circle

Moving a site between Linux and Windows servers: the differences that break it

Internal links: how to link your own pages so nothing stays hidden

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.