8bc1f3e41b672b03a339d56f81c8e253

Take a look at what I've written so far. In the way I'm using this it almost works perfect in all scenarios even removing hash # and everything after, but I have run into query strings.

I 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

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

Refactorings

No refactoring yet !

8bc1f3e41b672b03a339d56f81c8e253

Bryan Hadaway

May 30, 2010, May 30, 2010 14:14, permalink

No rating. Login to rate!

Okay, I've worked out the code that does exactly what I want (see below). But I need help refactoring it to adapt to the syntax of my code above. Thanks

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

Bryan Hadaway

June 7, 2010, June 07, 2010 08:20, permalink

No rating. Login to rate!

Your refactoring





Format Copy from initial code

or Cancel