This should work for what you’re looking to achieve;
add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
if ( ! is_user_logged_in() && ! is_page('one_time_login') ) {
wp_redirect( 'domain.com/sub', 301 );
exit;
}
}
This should be added to your theme (or child theme) functions.php file