Let's talk Contact us. No cost. No obligation.

Fill out this form and we will contact you with in 24 hrs.

    captcha

     

    Knowledge Base

    Changing WordPress 404 Not Found URL

    April 21, 2014

    Currently when a WordPress does not found any of the pages it goes to not found page but show same URL in browser which does not good for SEO purpose

    For instance, if you type www.yoursite.com/aaaaa

    It goes to ‘not found page’ but show same URL

    SEO guys need it should show www.yoursite.com/404.php instead of www.yoursite.com/aaaaa

    For this there are simple tweaks

    Open wp-includes/template.php and search for get_404_template()

    The existing function is as given below:

    function get_404_template() {

    return get_query_template(‘404’);

    }

    Replace this function with below given code

    function get_404_template() {

    if($_SERVER[‘REQUEST_URI’]!=’/404.php’){

    $url=”http://www.”.$_SERVER[‘HTTP_HOST’].”/404.php”;

    header(“Location: $url”);

    }

    return get_query_template(‘404’);

    }

    Name: Rajiv Kumar

    Designation: Technical Team Lead

    &

    Name: Praveen Chauhan

    Designation: Sr. Software Engineer