Posted By

iTony on 03/31/08


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

basicmagic
troynt
silentbob84


301 redirection with php


 / Published in: PHP
 

  1. <?
  2. header( "HTTP/1.1 301 Moved Permanently" );
  3. header( "Status: 301 Moved Permanently" );
  4. header( "Location: http://www.new-url.com/" );
  5. exit(0); // This is Optional but suggested, to avoid any accidental output
  6. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: tecto on July 6, 2010

Useful variation for automatically redirecting all traffic on a staging drupal site to the live site (replace stock index.php)

  1. $new_site = "[liveurl.com]";
  2. $new_location = "";
  3. if ($_GET["q"]) { $new_location = $_GET["q"]; }
  4. header( "HTTP/1.1 301 Moved Permanently" );
  5. header( "Status: 301 Moved Permanently" );
  6. header( "Location: http://$new_site/$new_location" );
  7. exit(0);

You need to login to post a comment.