How to redirect?

You can do something like this,

add_action('wp','special_redirect');

function special_redirect(){

  global $post;

  if( $post->ID ==  123 ) // put your post id
  { 
    if ( ! wp_get_referer() ) // false if you access directly 
    {
        wp_safe_redirect( get_home_url() ); // if so redirect to home
    }
  }
}

It should work. I’ve tested it.