301 Variable Redirection with PHP

- 1 min read
PHP logo
PHP logo

Yesterday I posted “301 REDIRECTION WITH PHP“, a mini how-to where I explained how to make a permanent redirection with PHP. But, if your case is similar to mine, that code it is not sufficient, and we must make a different redirection for each URL request.

To do that in one file, you must write the following code:


// Code for redirection
if (isset($_GET['?old_request'])) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.new-location.com/");
// End, you must repeat with each redirection


Share: Link copied to clipboard


Previous: 301 Redirection with PHP
Next: Los que se van – Michel Iguaz Calvo

Where: Home > Technical > 301 Variable Redirection with PHP