Created
June 2, 2014 06:37
-
-
Save halgatewood/aa3c22925452271c8c3f to your computer and use it in GitHub Desktop.
If the first parameter is not found then redirect to the second, If it is then do nothing.
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
function redirect_if_not_found( $item, $to ) | |
{ | |
if(!$item) | |
{ | |
// WHATEVER OTHER HEADER OPTIONS YOU WANT CAN GO HERE, LIKE A 301 | |
header("HTTP/1.1 301 Moved Permanently"); | |
// REDIRECT | |
header("Location: $to"); | |
} | |
} | |
// USAGE | |
redirect_if_not_found( $location, "/locations" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment