How to Make a Redirect in PHP

How to Make a Redirect in PHP

In this post we will give you information about How to Make a Redirect in PHP. Hear we will give you detail about How to Make a Redirect in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP header() Function

You can simply use the PHP header() function to redirect a user to a different page.

The PHP code in the following example will redirect the user from the page in which it is placed to the URL . You can also specify relative URLs.

<?php
header("Location: ");
exit();
?>

If you want to redirect the users from old page to a new page on a permanent basis then also mention HTTP response code in the header() function as shown in the following example, so that search engines transfer “page rank” from the old page to the new page.

<?php
// 301 Moved Permanently
header("Location: ", true, 301);
exit();
?>

 

Hope this code and post will helped you for implement How to Make a Redirect in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US