I would advise againt using anonymous functions for callback (when ever you can) as you can’t use a targeted remove_action
on it.
What Maythan8 answered will work but it can be done with fewer functions.
add_action('template_redirect', 'bt_maintenance_redirect');
function bt_maintenance_redirect () {
if (is_page(4848) || current_user_can('administrator')) return;
if (wp_safe_redirect(esc_url(home_url('maintenance/')))) exit;
}
You used esc_url_raw
but this function is used for escaping url before DB storage, if your url is just for output use esc_url
.
Also better to use wp_safe_redirect
if you are redirecting from and to the same host.