Code comes from the codex:

    <?php wp_redirect( get_permalink( $post->post_parent )); exit; ?>

I added the above, in an empty attachment.php page. When I visit an attachment page (eg. http://example.com/?attachment_id=2071) I get the error: 

"This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS"


Why?