Home » Web

Permanent Redirect with HTTP 301 in php

By: Zhiqiang Ma On: Jan 28, 2010 Views: 23 No Comment Print Email
Tags: , , ,

The htaccess method can be found here.

This is the method that use php to generate the HTTP 301 Redirect.

There are a lot of benefits of using HTTP 301 Redirect. These benefits can be found in the htaccess method post. I need not to repeat it again.

The header(“HTTP/1.1 301″) part must be used before the location part, otherwise PHP will automatically set the status code to HTTP/1.1 302 Found.

The code:

<?php
// Permanent 301 redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://pkill.info/");
exit();
?>

Read more:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.