# PHP Redirect to Another Page with the header() Function

> Use the PHP header() function with a Location directive to redirect users to another URL, followed by die() to stop further script execution

**URL:** https://sentry.io/answers/how-do-i-make-a-redirect-in-php/

---

## The Problem

You want to redirect from your web page to another web page using PHP. How can you do this?

## The Solution

The easiest way to add a redirect in PHP is to use the `header()` function.

```php
<?php
$url = "https://example.com";
header('Location: '.$url);
die();
?>
```

For example to redirect to `https://example.com` pass `'Location: https://example.com'` into `header`. In the example above, we concatenate the value in our `$url` variable to this.

It's a good idea to include the `die();` function after the redirect to stop the rest of the page from executing. Since you've redirected the user to another page, it's not necessary to execute the rest of the page.

---

*Source: [sentry.io/answers/how-do-i-make-a-redirect-in-php/](https://sentry.io/answers/how-do-i-make-a-redirect-in-php/)*
