Richard Parnaby-King

Web Developer – PHP, Zend Framework and Actionscript 3

Posted on | | No Comments

Canonicalisation issues occur when a webpage is able to be accessed via both www.yoursite.com/somepage and www.yoursite.com/somepage/, in severe cases this can cause the search engines to effectively index 2 identical copies of your site. Zend routes do not discriminate between pages that end in a slash or not – if a route does end in a slash, then the route removes it. Using a complex regex route it is possible to go to the correct version of the page (either keeping the slash or omitting it), however it is easier to use a canonical tag instead.

Include this line in the head tag of your layout file:

[php]

echo '';

[/php]

$this->url() will return the current url with corresponding parameters.

If you have a route ‘/products/:category’ and the user visits ‘/products/some-category/’ then the canonical tag will be generated as:

[html]
[/html]

Posted By:

Comments

  • ABOUT

    Having fifteen years of programming experience in PHP, Zend Framework and ActionScript3, I have a very strong working knowledge of object orientated programming.

    I am a PC Gamer! Playing FPS, RTS, RPG and the occasional MMO since 1996 I have a huge number of a variety of fast-paced games.

  • Recent Posts

  • Categories

  • RSS SUBSCRIBE TO OUR FEED