| Viewed 299 times

PHP how to redirect to another page

PHP how to redirect to another page

1 Answer
Mohammad Qandeel

There are many ways to redirect to another page in PHP

One of the most famous ways is Header Function

To make a simple redirect using header() function look to this example 

    header("Location: https://www.qandeelacademy.com"); 

save the code in .php file and open it will redirect to https://www.qandeelacademy.com

you can change the target to any URL or File like header("Location: /post/index.php"); 

using exit() function is important to prevent the script from executing after redirect 

note: HTTP headers must be sent before any type of content


Related Questions