PHP Redirect condition

If you want it to run as early as possible, which makes sense if you want to avoid loading unnecessary assets, put the code in a function in a Must Use Plugin, and hook that function to the muplugins_loaded action.

<?php

add_action( 'muplugins_loaded', 'wpd_my_redirector' );

function wpd_my_redirector() {

    // your code here
    // wp_redirect is not defined this early, so we use php's header

    if( $somecondition === true ){
        header( 'Location: ' . home_url( '/your-local-page/' ) );
        exit;
    }
}