Created
August 4, 2012 17:16
-
-
Save danielbachhuber/3258825 to your computer and use it in GitHub Desktop.
Quick way to handle redirects for old pages
This file contains hidden or 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 | |
/** | |
* Quick way to handle redirects for old pages | |
* | |
* From Happiness Bar at WordCamp SF 2012 | |
*/ | |
add_action( 'init', 'mea_redirects' ); | |
function mea_redirects() { | |
$mea_redirects = array( | |
// Enter your old URI => new URI | |
'/redundant_digital_control.html' => '/redundant-digital-control/', | |
); | |
foreach( $mea_redirects as $old_uri => $new_uri ) { | |
if ( false !== strpos( $_SERVER['REQUEST_URI'], $old_uri ) ) { | |
wp_safe_redirect( home_url( $new_uri ), 301 ); | |
exit; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment