doingword.com

How to make a permanent reditect with php headers

November 10th, 2007

Hi guys!
With this script you can make a permanent 302 redirection with php headers. This is very usefull when you want to make that google think that your domain.com is the same that www.domain.com.
Here the script:

if ($_SERVER[”HTTP_HOST”] == “www.domain.com”)
  1. {
  2. Header( "HTTP/1.1 301 Moved Permanently" );
  3. Header( "Location: http://domain.com".$_SERVER["REQUEST_URI"]);
  4. }

It’s very simple, but very usefull.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Entry Filed under: Php, SEO, tip


Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed