1

We have already 301 redirect from http://example.com to http://www.example.com and now we have redirect to https://www.example.com/

Now, the question is do we have to use the canonical i.e

<link rel="canonical" href="https://www.example.com" />

or

<link rel="canonical" href="http://www.example.com" />

Which one to choose and why?

2

The clue is in the name... whatever is the canonical URL should go in the rel="canonical" element.

The rel="canonial" element, as it's name suggests, contains a reference to the canonical URL. There can only be one canonical URL. Since you have implemented SSL and are redirecting everything to HTTPS then that is now your canonical URL and that is what goes in the rel="canonial" element. So...

<link rel="canonical" href="https://www.example.com/">

Btw, the hostname actually ends in a slash. And you don't need the self-closing slash in HTML (that's an XHTML hang over).

  • 1
    The self closing slash is useful for examples where you don't know what DOCTYPE will be used. The self closing slash is required in some, but permitted in pretty much all. – Stephen Ostermiller Oct 10 '16 at 15:31

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.