views:

12

answers:

1
function canlink() {
echo '<link rel="canonical" href="http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . '" />';
}

Need one version that removes just & and everything after and another that removes ? and everything after, I've been looking for a clean minimalist solution for the past 2-3 days with nothing close.

Thanks, Bryan

A: 

I figured out the code that does exactly what I want, now I just need help applying it to the syntax of my first code:

<link rel="canonical" href="http://&lt;?php echo $_SERVER["HTTP_HOST"] ?><?php echo parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH); ?>” />

Thanks, Bryan

Bryan Hadaway
Full solution here: http://www.bryanhadaway.com/super-simple-dynamic-canonical-link-code/
Bryan Hadaway