In PHP, you can use header function and create 301 redirect.

Here is a sample snippet.


<?php header('Location:', true, 301);  ?>

Code language: PHP (php)

The code below is an older version of this post.


header("HTTP/1.1 301 Moved Permanently");
header("Location: [](");


Code language: PHP (php)

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

powered by TinyLetter

Darryl Dias

I’m Darryl. I’m a 3D Artist, Programmer and Linux enthusiast. On this site I share my insights, tips and tricks, tutorials, methods and best practices.

Leave a comment

Your email address will not be published. Required fields are marked *