Last active
November 7, 2018 08:49
-
-
Save cubehrends/b526a9f1f1a4d6c70ac543e1de67b0f7 to your computer and use it in GitHub Desktop.
301 Moved Permanently vie PHP header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function redirectTo( $location ) { | |
header( 'HTTP/1.1 301 Moved Permanently' ); | |
header( 'Location: ' . $location ); | |
header( 'Connection: close' ); | |
} | |
switch ( $_SERVER['REQUEST_URI'] ) { | |
case '/post/an-uri-on-old-domain': | |
redirectTo( 'https://new-domain.com/a-new-uri/' ); | |
break; | |
case '/post/another-uri-on-old-domain': | |
redirectTo( 'https://new-domain.com/another-new-uri/' ); | |
break; | |
... | |
default: | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment