Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created August 4, 2012 17:16
Show Gist options
  • Select an option

  • Save danielbachhuber/3258825 to your computer and use it in GitHub Desktop.

Select an option

Save danielbachhuber/3258825 to your computer and use it in GitHub Desktop.

Revisions

  1. danielbachhuber created this gist Aug 4, 2012.
    20 changes: 20 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?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;
    }
    }
    }