wordpress 404 redirect to other url

If you are using wordpress as blog of your website blog and you are using other cms as your main website now you want any 404 of wordpress blog will redirect to that other cms 404 page then you use below code example to redirect your wordpress blog 404 page.

add_action('wp','determine_if_fourzerofour_page');
function determine_if_fourzerofour_page(&$arr){
    global $wp_query;
    if($wp_query->is_404){
        $url_redirect = 'http://www.exampledomain.com/404.php';
        header('Location: '.$url_redirect);
        die;
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: