Setting up rel canonical with drupal

i wanted to add a rel canonical tag to all pages on my site
inside page.tpl.php , i added:

$link1= request_uri();
$link2= '' . $link1;
print '<link rel="canonical" href="' .$link2 .'"/>';

now the problem is that whatever URL is typed the canonical link changes

for example has a different canonical link than and

is there a way to hard code canonical links so that they get the real URL path of my drupal page?

Drupal version: