Automatic Canonical Link Tags in Symfony


<link rel=”canonical”
href=”<?php echo url_for($sf_context->getRouting()->getCurrentInternalUri(true), true); ?>” />


More information about the new canonical link tags can be found


  1. Sven says:

    i had a problem using this, because getCurrentInternalUri returned something like @route?a=whatever&b=somethingelse and the call of url_for ended up in a “missing mandatory parameter” because it could not handle &

    so i added str_replace(“&”, “&”, $internaluri)

  2. tra la la says:

    Well on my end this link is not working even if I put str_replace…

    • e says:

      Keep in mind, this post was accurate as of 2009 when the version of Symfony was around 1.0. A lot has probably changed since then.

Leave a Reply

Your email address will not be published. Required fields are marked *