Dear folks, Im tied to a typical mistake of duplicate content that I wish to solve:
A web link within the browser shows:

Now, this isn't the canonical URL and that i would want the web page redirect to the known canonical url (around the condition the current page isn't already the canonical page)

<?php $canonical = ";

  header("HTTP/1.1 301 Moved Permanently" );
  header("Status: 301 Moved Permanently" );
  header("Location: " . $canonical);  // shows below picture, while url looks good


<html><head><link rel="canonical" href="<?=$canonical?></head>...</html>

Primary Question: Ways to get this to operate? Presently the non canonical url appears to wanna direct towards the canonical url (examined via Mind info) but when it arrives there PHP will get stuck and shows:

enter image description here

Minor Question: Performs this idea seem good for you? Since search engines like google don't use canonical so strictly and just utilize it like a hint, frequently saving the incorrect, non canonical url. Does the above mentioned rule allow it to be more strong through the 301 redirect for search engines like google in order to save the great versions searching results? Performs this also solve my duplicate content url problem?

Thanks greatly for the suggestions, ideas! Much appreciated.


if(isset($canonical) && ('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] != $canonical)) {
  header ('HTTP/1.1 301 Moved Permanently');
  header('Location: ' . $canonical);

To reply to your more general question, this isn't a tenable solution (unless of course your internet site is really small) since it requires you to definitely hard code the canonical Link to every page. As close to possible, you need to goal to produce a URL structure that has only one URI per resource. However, it will solve the immediate problem of search engines like google perceiving duplicate content.

Edit: Thanks Gumbo.

It appears canonical attempts to redirect too.
Make use of some HTTP sniffer to determine what Really occurs when you press some button. Grab yourself one like LiveHTTPHeaders Opera add-on of other things and find out what redirects being made.