PEAR Articles
  Home arrow PEAR Articles arrow Managing robots.txt using PHP: Generat...
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
Case Studies 
iPad Development 
Download TestComplete 
Forums Sitemap 
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? 
PEAR ARTICLES

Managing robots.txt using PHP: Generating Dynamic Syntax
By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2010-07-14

    Table of Contents:
  • Managing robots.txt using PHP: Generating Dynamic Syntax
  • Robots.txt using PHP example
  • Creating the PHP file and the static syntax
  • Upload the complete myrobots.txt.php to the website's root directory
  • Revise .htaccess to rewrite myrobots.txt.php to robots.txt

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Managing robots.txt using PHP: Generating Dynamic Syntax


    (Page 1 of 5 )

    Managing your robots.txt files can be tricky at the best of times. This article will show you how to use PHP to dynamically handle these files, thus relieving the webmaster of a tedious and time-consuming task.

    The classic implementation of robots.txt is very simple. All the webmaster needs to do is to put the syntax in a text file, then name it obots.txt to upload it to the website root directory and its done.

    The most popular way to edit robots.txt is manually. However manual editing can be a pain, especially if the webmaster has too many URLs to add on a periodic basis that do not have short cuts like using wild cards or any other valid methods.

    Robots.txt is very useful for several reasons, such as duplicate content prevention (useful in SEO), improving bandwidth and restricting bots from crawling sensitive parts of the website.

    This tutorial will take a unique approach to managing robots.txt files. It will use PHP to "dynamically" edit or generate robots.txt syntax. With this method fully implemented, the webmaster will not need to worry about manually updating because the PHP script will take care of itself, generating syntax according to what it has been programmed to do.

    Approach to robots.txt implementation with PHP

    The general concept of this implementation can be visualized in a flow chart, as shown below:

    The overall strategy is to write the syntax in a PHP script (you can name it  anything you like), and then render it as Content-Type:text/plain so that  browsers or user agents will see it as a text file. Finally since this is a PHP file, the extension is .php, so you will need to use .htaccess to rewrite myrobots.txt.php to its standard name, robots.txt

    More PEAR Articles Articles
    More By Codex-M


     

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning





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