3

I force usage of trailing slash for all of my pages under https://example.com, however the main domain remains without it - from what I've read it's OK to do so, but I'm not sure how does Google 'understand' it.

So I got:

  • https://example.com (https://example.com/ changes to https://example.com)

  • https://example.com/blog/

  • https://example.com/blog (which changes to https://example.com/blog/)

  • etc.

Questions:

  1. is it ok that my main page remains without trailing slash? From what I've observed it's typical behaviour of 99% domains.
  2. should I use in Google search console https://example.com or https://example.com/ ? Currently I got https://example.com/ and I wonder if it's a huge problem.
  3. Which one should I indicate in a sitemap? Currently I got https://example.com

If someone is interested, I paste also a part of my .htaccess file:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

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

RewriteRule ^blog/$ sites/blog.php [NC,L]
RewriteRule ^mobile/$ index.php [NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
4

When it comes to the "main domain" (ie. no apparent URL path) there is really only one URL. That is, the one with a trailing slash:

//example.com/

However, Google "understands" this and essentially "fixes" any URL where the slash is omitted. So, //example.com and //example.com/ are really the same. So, yes, it doesn't much matter.

Google always shows a trailing slash on the main domain in the SERPs.

Any URL you see in the browsers address bar where the trailing slash on the domain is omitted is purely cosmetic - in the browser. These days browsers are a bit notorious for making the visible URL look more friendly (omitting the scheme and even the query string in some browsers by default). However, if you look at the underlying request the browser is making, it is the same, regardless of whether you type the trailing slash or not. The trailing slash is present in the request (as the URL-path), because the HTTP request is simply not valid with an entirely "empty" URL-path.

https://domain.com (https://domain.com/ changes to https://domain.com)

To be clear, it is the browser that removes the trailing slash in the visible URL in the address bar, before the request is even sent to your server. As mentioned, this is purely cosmetic. Google Chrome and Firefox remove the trailing slash, IE11 does not. Opera removes the trailing slash (as well as the query string!) by default, however, this can be changed in Settings > User interface > "Show full URL in combined search and address bar" - you then get to see everything... the scheme, trailing slash on the domain and query string!

You've quoted your .htaccess code... However, your code is not doing anything with regards to slashes on the main domain. And nor can you influence the trailing slash on the main domain with server-side code.

To answer your specific questions...

  1. is it ok that my main page remains without trailing slash? From what I've observed it's typical behaviour of 99% domains.

This has nothing to do with the domain, or even your server. In order for the user agent to construct a valid HTTP request there must be a slash present in the URL-path. But yes, it's "OK".

  1. should I use in Google search console https://example.com or https://example.com/ ? Currently I got https://domain.com/ and I wonder if it's a huge problem.

I don't think you really have a choice. GSC automatically appends a trailing slash on the domain.

  1. Which one should I indicate in a sitemap? Currently I got https://example.com.

Strictly speaking you should include the trailing slash. The Google references I've seen, and the Sitemaps Protocol site itself all reference the main domain URL with a trailing slash. However, in reality it's not really going to matter. Any URL processing engine will "fix it".

Related question:
Is trailing slash automagically added on click of home page URL in browser?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.