May
10
2006
301 redirect using PHP

If you read my previous post about duplicating your main page, here's a solution about doing a 301 redirect from http://www.yourdomain.com/index.php to http://www.yourdomain.com.
This one is contributed by a friend of mine Benj of actiononline.biz
This is a 301 redirect using PHP program.
<?
$_SERVER[HTTP_HOST] = strtolower($_SERVER[HTTP_HOST]);
if($_SERVER[HTTP_HOST]=="actiononline.biz" or
$_SERVER[REQUEST_URI]=="/index.php") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.actiononline.biz");
exit();
}
?>
2 Comments
Other Links to this Post
RSS feed for comments on this post. TrackBack URI
By Indie Music, May 11, 2006 @ 7:34 am
ANother option is to stick this in your .htaccess file:
RewriteCond %{HTTP_HOST} ^www\.example\.com/index.php$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
By Matt, March 30, 2007 @ 1:40 pm
RedPHP.com has a similar script to this already setup, with more features:
http://www.redphp.com/makeitwww/