I found the Permalink Fix & Disable Canonical Redirects Pack plugin takes care of the problem but I would love to have a better solution.
Turns out the plugin interferes with the WPtouch plugin… 🙁
Located the problem!
In functions.php there’s this snippet:
/**
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
*/
function toolbox_enhanced_image_navigation( $url ) {
global $post;
if ( wp_attachment_is_image( $post->ID ) )
$url = $url . '#main';
return $url;
}
add_filter( 'attachment_link', 'toolbox_enhanced_image_navigation' );
If I take it out, the redirect loop disappears but judging from the description (“previous/next”) it also means I can’t have galleries now anymore?
I found that removing the following part from the code
. main '#main'
did the trick.