How to redirect page in php? 301 and 302 Redirect Page

page redirect:

<?php

header('Location: mypage.php');

?>

do you think this is SEO friendly? The answer is Absolutely not!!
There are two different kind of redirection as per the SEO:
1. 302 redirection ? which is a temporary redirection.
2. 301 redirection ? and this one is a permanent redirection.
If you simply give a header function and the location, it means 302 redirection, which is not good as per the SEO point of view, If you decided to redirect the page permanently then this is wrong.
The correct way of doing is this:

Example : Redirect page.



<?php

header( 'Location: mypage.php', true, 301 );

?>



Redirect a page after a few seconds in PHP

<?php

//refresh the page after 5 seconds
header('Refresh: 5;url=yourpage.php');

?>





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here