It shouldn't matter where you place it in functions.php.
In the page editor, there should be a "Custom Fields" box. The name should be mobile_redirect and the value should be the URL.
Don't forget you'll need a function for actually checking if mobile. I had no idea there is actually a WordPress function for this, wp_is_mobile. So I'd modify the function to be:
function do_home_redirect() {
if( !is_front_page() ){
return;
}
if( wp_is_mobile() ){
$redirect = get_post_meta( $post->ID, "mobile_redirect", true );
if( $redirect ) {
header('Location: ' . esc_url( $redirect ));
exit;
}
}
}
add_action( 'init', 'do_home_redirect' );