Alberto Roura

301 Variable Redirection with PHP

17 March 20141 min read

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");
// End, you must repeat with each redirection