How to prevent the default home rewrite to a static page

The redirect is thanks to redirect_canonical() – we can simply swoop in with a filter and disable it for the front page:

function wpse_184163_disable_canonical_front_page( $redirect ) {
    if ( is_page() && $front_page = get_option( 'page_on_front' ) ) {
        if ( is_page( $front_page ) )
            $redirect = false;
    }

    return $redirect;
}

add_filter( 'redirect_canonical', 'wpse_184163_disable_canonical_front_page' );

Now you can access the front page at the root and by it’s slug, no redirect.

Leave a Comment