Home arrow PHP arrow Page 2 - Using the Link Rel Canonical Tag

Theory of Implementation - PHP

The link rel canonical tag lets you solve canonical issues for your URL without having to resort to 301 redirects or other potentially complicated approaches. This article explains how to take advantage of the tag in your PHP-powered web sites.

TABLE OF CONTENTS:
  1. Using the Link Rel Canonical Tag
  2. Theory of Implementation
  3. Implementation Steps
  4. Implementing a Canonical Version, First Scenario
  5. Implementing Canonical Version for a Secure Website
By: Codex-M
Rating: starstarstarstarstar / 6
May 07, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To understand how to implement this, we must illustrate first how 301 redirection is used to solve this type of problem. Consider the example below, which illustrates a typical non-www and www canonical issue:

Googlebot sees a non-www URL during a crawling session ---> http://somewebsite.com/myfile.php ---> if non-www ---> server will do a 301 redirect to the www canonical version ---> http://www.somewebsite.com/myfile.php ---> Googlebot indexes the www version

Therefore, this means that if Googlebot sees any non-www URL, the server will do a 301 redirect so that Googlebot will index the canonical version.

What should happen when we use the link rel canonical element? See the diagram below:

Googlebot sees a non-www URL during a crawling session ----> http://somewebsite.com/myfile.php ----> Google sees the link rel canonical tag in the head section of this file <link rel="canonical" href="http://wwww.somewebsite.com/myfile.php" /> ------> Google indexes the canonical URL provided.

This means that we have to place this tag in the <head> section so that if any non-www URL is being crawled, Googlebot will fetch the canonical www URL.



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap

Dev Shed Tutorial Topics: