Search code snippets, questions, articles...

Go to another page in PHP

<?php
    header("Location: page_name.php"); //You can pass relative url of page or full url of page
    exit();
?>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

If you want to redirect to a page in PHP, you can use the 'header' function for that. You can either pass the full URL of the page to the Location or relative path of the page.

Example 1

Passing relative URL of the page

<?php
    header("Location: ../article/blog.php");
    exit();
?>

Example 2

Passing full or absolute URL to the Location

<?php
    header("Location: https://devsheet.com/u/");
    exit();
?>

Search Index Data (The code snippet can also be found with below search text)

Redirect to a page in PHP
Was this helpful?
0 Comments