$fullurl = ($_SERVER['REQUEST_URI']); $trimmed = trim($fullurl, ".php"); $canonical = rtrim($trimmed, '/') . '/'; ?>