PHP
  Home arrow PHP arrow Page 3 - Using the Link Rel Canonical Tag
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Using the Link Rel Canonical Tag
By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-05-07


    Table of Contents:
  • Using the Link Rel Canonical Tag
  • Theory of Implementation
  • Implementation Steps
  • Implementing a Canonical Version, First Scenario
  • Implementing Canonical Version for a Secure Website

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using the Link Rel Canonical Tag - Implementation Steps
    ( Page 3 of 5 )

    We will make a flowchart of the PHP script that will be able to place the canonical tag at the source of any non-canonical URL issues without the use of .htaccess or redirections.

    Basically there are four domain canonical scenarios:

    • A domain using www and using the non-secure protocol (http://) as the canonical version. Most of the domains on the Internet fit into this scenario.
    • A domain using www and the secure protocol (https://) as the canonical version. A good example of this is PayPal.
    •  A domain using non-www and using the non-secure protocol (http://) as the canonical version. This makes for easier typing of domain names in the browser for faster user access. A good example of this is Digg.
    • A domain using non-www and using the secure protocol as their canonical version. This alternative is not popular, although some good sites use this type of canonical version solution, such as https://launchpad.net/

    Each of these URL canonical scenarios requires different PHP scripts, but the flow of implementation is the same. Here is an example that illustrates a site using http:// and www: as their canonical version.

    Step 1: If the domain is using session IDs, this should be stripped off first as it is not needed as part of the canonical version.

    Step 2: Check to see if the requested protocol is http://. If it is not, return the http version to the browser and append results with Step 3.

    Step 3: If the requested URL dos not use www, append www to the URL; otherwise, return it to the browser.

    The final canonical URL should:

    • Not use a session ID.
    • Contain the www version. 
    • Use the canonical protocol, which is http://

    In the rest of this article, I'll show you the recommended PHP canonical scripts for the four scenarios discussed above.



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek