PHP: 301 Redirect

Sep 15, 2015
In [PHP](http://php.net) you can use `header` function and create 301 redirect.

Here is a sample snippet.

Update:

header('Location: http://example.com', true, 301);  

The code below is an older version of this post.

header("HTTP/1.1 301 Moved Permanently");

header("Location: [http://example.com](http://example.com)");

This will redirect the PHP page you have added this into example.com, you can change example.com 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.


If you like this content, please consider buying me a coffee.

Buy me a coffeeBuy me a coffee

You will get access to contributer exclusive resources and content.

Thank you!



Darryl Dias

I am a student, artist, and author currently living in Florida. My interests range from technology to arts. I am also interested in programming, writing

Analytics by GoSquared