here a simple WordPress rewrite rule to get the job done:
add_action('generate_rewrite_rules', 'attachment_rewrite_rule_14924');
function attachment_rewrite_rule_14924($wp_rewrite){
$new_rules = array();
$new_rules['attachment/(\d*)$'] = 'index.php?attachment_id=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
just add this code to your theme’s functions.php file and save.
*note: the index.php is regardless of your existing URL structure.