two active templates for one post

If you look at the function you’ll see there’s an error :

function detail_rewrite_rule( $rules ) {
  $newrules = array();
  $newrules['(.+?)/([^/]+)(/[0-9]+)?/detail/?$'] = 'index.php?category_name=$matches[1]&name=$matches[2]&page=$matches[3]&detail=1'; 

  return $newrules + $rules;
}
add_filter( 'rewrite_rules_array','detail_rewrite_rules' );

The callback is not the same : detail_rewrite_rule, detail_rewrite_rules.

In the add_filter you have to provide the same name for function. Otherwise this won’t be hooked in WordPress. So you can fix it with :

add_filter( 'rewrite_rules_array','detail_rewrite_rule' );//without the s