Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have two single woocommerce installs (not multisite) that publish the same content (products etc). i want to add a cross domain level rel canonical to the second domain, such that -

www.domain2.com/any-url/ will have a rel canonical of www.domain1.com/any-url/

it seems only way to do it is add rel canonical to every single URL manually. is there not an option to set a top level rel canonical for the whole domain?

share|improve this question
What do you mean by 'manually'? If you want to have a canonical link that equals the current URL with just another domain, you can simply put that line into your header. If you want to do this (i.e., include this link) only for certain templates, you have to check if the current page is of that kind. –  t f Mar 7 '13 at 11:32
@t-f yes thats what i meant. what line do i need to add into the header? –  user1768787 Mar 7 '13 at 11:35

1 Answer 1

Well, the basic idea is to put this line into your header.php:

<link rel="canonical" href="http://YOUR-DOMAIN.TLD<?php echo $_SERVER["REQUEST_URI"]; ?>" />

You now have to test cases (if you want to apply the link to certain pages only).

See $_SERVER for documentation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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