Search Optimization
  Home arrow Search Optimization arrow Page 6 - Preparing Your New Site for Structural...
SEO Chat Forums  
Choosing Keywords  
Google Optimization  
Link Trading  
MSN Optimization  
Search Engine News  
Search Engine Spiders  
Search Optimization  
Web Directories  
Website Marketing  
Website Promotion  
Website Submission  
Yahoo Optimization  
SEO Tools
Adsense Calculator
AdSense Preview
Advanced Meta-Tags
Alexa Rank Tool
Check Server Headers
Class C Checker
Code to Text Ratio
CPM Calculator
Domain Age Check
Domain Typos
Future PageRank
Google Dance
Google Keywords
Google Search
Google Suggest
Google vs Yahoo
Indexed Pages
Keyword Cloud
Keyword Density
Keyword Difficulty
Keyword Optimizer
Keyword Position
Keyword Typos
Link Popularity
Link Price Calculator
Meta Analyzer
Meta Tag Generator
Multiple Link Popularity
Page Comparison
Page Size
PageRank Lookup
PageRank Search
Robots.txt Generator
ROI Calculator 
S.E. Comparison 
S.E. Keyword Position 
Site Link Analyzer 
Spider Simulator 
URL Redirect Check 
URL Rewriting 
Mobile Linux 
APP Generation ROI 
IBM® developerWorks 
SEO 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? 
SEARCH OPTIMIZATION

Preparing Your New Site for Structural Changes
By: Bill Sterzenbach
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2004-02-25

    Table of Contents:
  • Preparing Your New Site for Structural Changes
  • The Solution
  • Improper Redirect: Simple Redirection Header
  • Proper Redirect - Redirection with 301 Code
  • Moving Pages
  • The Code

  • 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


    Preparing Your New Site for Structural Changes - The Code


    (Page 6 of 6 )

    This is the code you need to see all this in action. Enjoy!

    Database Creation Script

    CREATE TABLE relocatedcontent (
      URI_ID int(11) NOT NULL auto_increment,
      OldURI varchar(100) NOT NULL default '',
      NewURI varchar(100) NOT NULL default '',
      PRIMARY KEY  (URI_ID)
    ) TYPE=MyISAM CHARSET=latin1;

    #
    # Dumping data for table 'relocatedcontent'
    #

    INSERT INTO relocatedcontent VALUES("1", "/OldPage.htm", "NewPage.htm");

    .htaccess code

    # .htaccess

    ErrorDocument 404 /404.php

    404 PHP Script

    <?
    // 404.php

    include("db.php");

    // Get the name of the file requested into an
    // array split on the "?"
    $FileParts = explode ( "?", $_SERVER["REQUEST_URI"]);

    // Lets just use everything prior to the question
    //mark, as the upcoming query will not match if
    //there are arguments in the string.
    $FileRequested = $FileParts[0];

    // Get the server name to generate an absolute
    //path for the redirect
    $ServerName = $_SERVER["SERVER_NAME"];

    // Setup the DB object for our query
    $q = new DB;
     
    // Look and see if the requested file is in the
    // database
    $query = "SELECT * from RelocatedContent WHERE OldURI = '$FileRequested'";

    // Run the query
    $q->RunQuery($query);

    // If we found a match..
    if ($q->GetNextRecord()){
     $NewURL = $q->Fields("NewURI");
     header("HTTP/1.1 301 Moved Permanently");
     header("Location: http://$ServerName/$NewURL");
    }

    // If we made it this far, we have a "real"
    // 404 on our hands, show 'em some options..
    include("404form.htm");
    ?>

    Database Connection Code

    <?

    //db.php

    class DB {
     var $classname = "DB";
     var $Host = "localhost";
     var $Database = "SystemDatabase";
     var $User = "SomeUserName";
     var $Password = "SomePassword";
     var $result;
     var $line;
     var $link;
     
     function DB() {
      $this->link = mysql_connect($this->Host,$this->User,$this->Password) or die("Could not connect");
      mysql_select_db($this->Database) or die("Could not select database");
      return $this->link;
     }
     
     function RunQuery($val){
      $this->result = mysql_query($val) or die(mysql_error());
      return $this->result;
     }
     
     function GetNextRecord(){
      $this->line = mysql_fetch_assoc($this->result);
      return $this->line;
     }

     function Fields($val){
      return $this->line[$val];
     }
    }
    ?


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    SEARCH OPTIMIZATION ARTICLES

    - Implementing Six Sigma Methodology for SEO
    - Introducing Six Sigma Methodology for SEO
    - What is Mobile SEO?
    - Using Lynx for SEO Analysis
    - Mastering Lynx (Open Source Text Browser) fo...
    - More Blogging Tips: Cooking with Gas
    - Blogging Tips from Julie and Julia
    - SEO Essentials: the Proper Web Server and Pl...
    - Steps to Higher Rankings and Traffic
    - Building Linkable Pieces and Titles
    - Page Rank Sculpting
    - Page Rank Optimization
    - ClickTale Review
    - Final Issues: Moving Blogger to WordPress wi...
    - Avoid the Mistakes New SEOs Make



     



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