<?php

function canonical()
{
    // TODO httpS
    $url = "http://{$_SERVER['HTTP_HOST']}";
    $url .= explode('?', $_SERVER['REQUEST_URI'], 2)[0];
    return '<link rel="canonical" href="' . htmlspecialchars($url) . '">';
}