Redirect Page to Another URL in PHP

- 1 minute read

The below PHP code uses the built-in header function to redirect the user to


This more complete and thorough snippet replaces the previous status code and sets it to 301, before exiting:

header('Location:', true, 301);

There are actually a number of other ways you could go about doing this, but this is my favorite, because I find it to be the most concise and easiest to remember.

Link to this section Conclusion

That’s all! Happy redirecting!