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: https://example.com', true, 301); exit();
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.
That’s all! Happy redirecting!