By serg

2012-07-06 23:11:14 8 Comments

My home page could be potentially linked as:

(the same page is served for all those URLs)

I am thinking about defining a canonical URL to make sure Google doesn't consider those urls to be different pages:

<link rel="canonical" href="/" /> (relative)
<link rel="canonical" href="" /> (trailing slash)
<link rel="canonical" href="" /> (no trailing slash)

Which one should be used? I would just slap / but messing with canonical seems like a scary business so I wanted double check first.

Is it a good idea at all for defining a canonical URL for a home page?


@Ilmari Karonen 2012-08-06 14:36:03

According to RFC 2616 (HTTP/1.1), section 3.2.2, the URLs and are equivalent, and HTTP clients must normalize the former to the latter before sending the request to the server:

"If the abs_path is not present in the URL, it MUST be given as "/" when used as a Request-URI for a resource (section 5.1.2)."

where section 5.1.2 says:

"Note that the absolute path cannot be empty; if none is present in the original URI, it MUST be given as "/" (the server root)."

RFC 3986 (URI Generic Syntax) confirms this in section 6.2.3, Scheme-Based Normalization, noting that:

"For example, because the "http" scheme makes use of an authority component, has a default port of "80", and defines an empty path to be equivalent to "/", the following four URIs are equivalent:

In general, a URI that uses the generic syntax for authority with an empty path should be normalized to a path of "/". Likewise, an explicit ":port", for which the port is empty or the default for the scheme, is equivalent to one where the port and its ":" delimiter are elided and thus should be removed by scheme-based normalization. For example, the second URI above is the normal form for the "http" scheme."

Technically, the normalization described in RFC 3986 section 6.2.3 is optional for implementations that e.g. merely index URLs, although RFC 2616 makes it mandatory for clients wishing to actually send HTTP requests. Still, given that the standard permits such normalization, and given that search engines generally don't want to deliberately add duplicates to their index, one can be reasonably sure that just about all search engines will be normalizing all those URLs to be the same.

Thus, it makes no difference to either browsers or search engines whether you use or They're equivalent.

@Stephen Ostermiller 2013-07-22 14:15:12 and may be equivalent, but is the canonical one because it is what URIs must be normalized to. So I would use it in the canonical meta tag.

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Excluded from Google: Duplicate, submitted URL not selected as canonical

3 Answered Questions

4 Answered Questions

1 Answered Questions

[SOLVED] How to keep friendly URLs consistent?

1 Answered Questions

[SOLVED] Is trailing slash automagically added on click of home page URL in browser?

  • 2012-10-14 05:50:48
  • Question Overflow
  • 18094 View
  • 18 Score
  • 1 Answer
  • Tags:   url browsers

2 Answered Questions

Sponsored Content