Buy me a Coffee

PHP: 301 Redirect

1 min read

In PHP you can use <code class="highlighter-rouge">header function and create 301 redirect.

Here is a sample snippet.


``` header('Location:', true, 301); ```
The code below is an older version of this post.
``` header("HTTP/1.1 301 Moved Permanently");


</div>This will redirect the PHP page you have added this into `<code class="highlighter-rouge">`, you can change `<code class="highlighter-rouge">` to any domain you prefer, you can do the same to file with extensions and subdomain.

Thanks to, Christian Häusler for the tip.

Thank you for reading.