Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I have a page with the URI lets say www.example.com/page there might be the possibility that users or links end up sending the user to pages like this: www.example.com//////page?

I could just use a canonical on the page which refers to www.example.com/page, but my fist question is whether a redirection via PHP with:

header ("Location: http://www.example.com/page")

might be more useful. It is definitely more user-friendly, which should be the overall goal.

My second question now is, in case I use the canonical, should I include the canonical tag into the page standard html or should I just put it in there via PHP if the canonical differs from the current page URI?

share|improve this question

The redirect is the better solution, as it stops the erroneous URLs ever being linked to or shared, and so should help crawl efficiency (i.e., search engines shouldn't have to crawl multiple non-canonical versions of pages, thereby wasting time that could be spent elsewhere on your site).

I'd do your redirects on the server though, if possible. A fairly simple regular expression will catch all manner of undesirable URL variants (e.g., jumbled case, with and without trailing slash, etc.).

You don't need to apply the canonical link element conditionally: it can always be there, regardless of whether the page is being shown on a non-canonical URL or not. Even Google do this.

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.