It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum Script-archive

301 Redirect from http:// to http://www.

Share your completed scripts.

Moderator: Malcolm

301 Redirect from http:// to http://www.

Postby webmaster on Tue Dec 27, 2005 10:19 pm

This code is a 301 redirect from: http://yoursite.com to http://www.yoursite.com

[php]<?php
if (!strstr($_SERVER['HTTP_HOST'],'www')){
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
?>[/php]
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby sevenaces on Fri Apr 20, 2007 6:15 pm

must have took you some time to color it.
nice script
User avatar
sevenaces
50+ Club
 
Posts: 63
Joined: Thu Sep 28, 2006 7:44 pm

Postby webmaster on Sat Apr 21, 2007 8:16 am

The forum has a functions that highlights PHP script like this, I did not color it manually :)
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden


Who is online

Users browsing this forum: No registered users and 0 guests