-
-
Save ivankruchkoff/841885495873a1fe2ec0645b079f927e to your computer and use it in GitHub Desktop.
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 vip_substr_redirects( $vip_redirects_array = array(), $append_old_uri = false ) { | |
if ( empty( $vip_redirects_array ) ) | |
return; | |
// Don't do anything for the homepage | |
if ( '/' == $_SERVER['REQUEST_URI'] ) | |
return; | |
foreach ( $vip_redirects_array as $old_path => $new_url ) { | |
if ( substr( $_SERVER['REQUEST_URI'], 0, strlen( $old_path ) ) == $old_path ) { | |
if ( $append_old_uri ) | |
$new_url .= str_replace( $old_path, '', $_SERVER['REQUEST_URI'] ); | |
wp_redirect( $new_url, 301 ); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment