Support » Plugin: 404page - your smart custom 404 error page » 404 Migration Bridge

  • Resolved neilticktin

    (@neilticktin)


    Hi Peter,

    We have a large site that I’m moving from drupal to WordPress gradually. For the WordPress site … for now … I want to have the 404 not show a 404 page, but instead redirect to the old site as the page may be there. If it’s still not there, the old drupal site will give a 404.

    For example, http://www.xyz.com/transition-guide/index-002.html doesn’t exist on the new site (yet), but it does on the old site, so I want http://www.xyz.com/transition-guide/index-002.html to effectively redirect to preserve.xyz.com/transition-guide/index-002.html … by simply replacing http://www.xyz.com with preserve.macdtech.com

    After the migration is completed — over a period of months in all likelihood, I can remove this and do a traditional 404. In other words, my wordpress site at http://www.xyz.com won’t have any 404 page … it would always redirect to preserve.

    I’ve hacked something together for this now — but I’d prefer to use a plugin.

    Is this something your 404 plugin can do? If not, you may want to consider it a feature request.

    Thanks!

    Neil

    • This topic was modified 2 years, 6 months ago by neilticktin.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Peter Raschendorfer

    (@petersplugins)

    Hi Neil,

    the purpose of this plugin is the creation of a custom 404 error page. What you need is something completely different. This is not possible with my plugin and I will not include such a functionality in future.

    What you want to achieve should be very easy. Should be something like this (untested):

    add_filter( '404_template', function( $args ) {
      wp_redirect( str_replace ( '//www.xyz.com', '//preserve.xyz.com', ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http' ) . '://' .  $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"] ) );
      exit;
    } );

    Regards,
    Peter

    Peter,

    Understood and thanks for the snippet too!

    Am I correct in the snippet that:

    isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS']

    should have the first HTTPS be HTTP like this…

    add_filter( '404_template', function( $args ) {
      wp_redirect( str_replace ( '//www.xyz.com', '//preserve.xyz.com', ( isset( $_SERVER['HTTP'] ) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http' ) . '://' .  $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"] ) );
      exit;
    } );

    Thanks again!

    Neil

    Plugin Author Peter Raschendorfer

    (@petersplugins)

    Hi Neil,

    nope, HTTPS is correct.

    You’re welcome.

    Regards,
    Peter

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘404 Migration Bridge’ is closed to new replies.