I'm just working through some PHP to set up a canonical link for each page on one of my websites and I'm wondering what's the correct link for the home page:

Is it:

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


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

I've always tried to link to the home page without the trailing slash.

2 Answers 2


I feel I should clear this up. Tim Fountain is correct in his comment.

Unlike directories, a domain with a trailing slash is exactly, 100% the same as one without. In other words, it's literally not possible to choose one or the other. So it makes zero difference which you put into your canonical.

  • It might be a good idea to just make trailing slash a habit.
    – keepkalm
    Feb 16, 2021 at 23:30
  • @keepkalm Why? It makes literally no difference. Feb 17, 2021 at 12:05
  • If you had to make one rule for consistency what would it be?
    – keepkalm
    Feb 18, 2021 at 2:25
  • Consistency with what? There is only one home page so only one place where you will use a canonical with just the domain. Feb 18, 2021 at 12:36

Adding or omitting a trailing slash to canonical links really doesn't matter to search engines, providing they both work.

It maybe be best however to stick with one or the other because Google treats each of these URL's separately, which can lead to duplicate content. See this for more on that: Google Webmaster Central Blog: To slash or not to slash

As indicated in that, it may also be wise to do a 301 redirect from the URL that you don't use to the URL that you do use to further avoid duplicate content.

In short, if you don't use a trailing slash in the links in your content, then don't use it in the canonical link either, and follow the same convention in your sitemap too.

  • 2
    If you're not experienced with .htaccess file config options, then the simplest way is to look at the headers (e.g., 200 or 301) returned by the server, as covered in the link in my answer. There are online sites that will display server headers, and browser extensions/plugins that will do this too.
    – dan
    Jun 12, 2013 at 7:08
  • 2
    FYI: IE is notorious for caching address history. I'd trust Chrome or Firefox more for development.
    – dan
    Jun 12, 2013 at 7:16
  • 3
    I think the homepage is a special case here. Chrome and Firefox may hide the trailing slash from the URL (in the same way that they hide the http://) but it is still there. If you visit http://example.com, the request URI the browser will send to the server is for /. Jun 12, 2013 at 9:25
  • 1
    Nemmy, you can check if your home page URL has a trailing slash redirect, or not, with a header check such as: webconfs.com/http-header-check.php
    – Max
    Jun 12, 2013 at 10:06
  • 1
    @nemmy I don't think anyone is saying that. In any case, I would stick with what Google has to say about it in the link provided. Look at number 4 there.
    – dan
    Jun 13, 2013 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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