public function canonicalUrl($url)
{
if (strlen($url)) {
if ($url[0] == '/') {
// If the URL begins with a "/", the following is the
// canonical URL
return substr($url, 1);
} else {
// Else, the canonical name is under the current dir
if ($this->getDirName()) {
return $this->canonicalize($this->getDirName() . '/' . $url);
} else {
return $this->canonicalize($url);
}
}
}
return null;
}