fbpx
Friday, December 8, 2023
Hire us on Freelancer.com for web development service
HomeFaqHow to make redirect in Php

How to make redirect in Php

Creating a PHP redirect is a common task in web development. A redirect is a way to send a user from one web page to another automatically. There are two primary types of redirects: 301 (permanent) and 302 (temporary) redirects. To redirect a user to a different page, just utilize the PHP header() function.

<?php
header("Location: http://www.example.com/another-page.php");
exit();
?>

If you would like to permanently redirect viewers from the old page to the new page, include the HTTP response code in the header() function, as shown in the example below.

<?php
// 301 Moved Permanently
header("Location: http://www.example.com/another-page.php", true, 301);
exit();
?>

For further insights and resources on PHP redirects and web development, be sure to check out Developertricks. This informative website offers a wealth of knowledge on web development, PHP, and related topics.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Hire Us

Categories