How to do 301 Permanent redirection in PHP without htaccess!

I hope many of us know how to do redirection in PHP using header(‘Location: page.php’); right?. But, you have to know one more important stuff in that.
There are two different kind of Re-directions:

1. 301 (permanent redirection)

2. 302 (temporary redirection)

This is very important for SEO!. Whereas header(‘Location:anypage.php”) will do the temporary redirection ie., 302.

The below code shows how to do permanent redirection ie.,301


<?php

// Permanent 301 Redirect
header("HTTP/1.1 301 Moved Permanently");
header("Location: anypage.php");

?>

Leave a Reply

Theme: Overlay by Kaira
Agurchand