04.17 php saved
phpappdev256
Tags add more
301 redirect, AppError and perminant redirect  
Note
phpappdev256 did not leave a note
  1. //  File: /app/error.php
  2. //  Purpose: To perminantly 301 Redirect URLS
  3. //  from the Base (/) Directory to other locations
  4. //  so as to not lose page rank or traffic.
  5.  
  6. <?php
  7. class AppError extends ErrorHandler{
  8.  
  9.     var $redirect_list = array(
  10.             'asdfwefs' => 'http://www.google.com',
  11.             'whats_up_doc' =>'/articles/view/whats_up_doc'
  12.         );
  13.  
  14.     function __construct($method, $messages) {
  15.         if (!empty($messages[0]['url'])) {
  16.             if (!strstr($messages[0]['url'], '/')) {
  17.                 if (array_key_exists($messages[0]['url'], $this->redirect_list)) {
  18.                     header("HTTP/1.1 301 Moved Permanently");
  19.                     header("Location: " . $this->redirect_list[$messages[0]['url']]);
  20.                     exit;
  21.                 }
  22.             }
  23.         }
  24.         parent::__construct($method, $messages);
  25.         exit;
  26.     }
  27. }
  28.  
  29. ?>
Parsed in 0.045 seconds, using GeSHi 1.0.7.14

Modify this Paste