Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.