I'm having an issue with media/attachment files and I'm not quite sure how WordPress is returning the URL that it does. I've noticed that I can add anything as a subdirectory structure before a media slug and WordPress will return a 200 header and somehow direct to the correct media. For example:
When the correct URL should be:
The incorrect URL returns a 200 HTTP header and the attachment template loads fine even with the correct file. I thought this was happening as a result of something in the canonical.php file but after quite a bit of testing and even deleting everything in that file (in a test environment), WordPress is still doing this. If I do this for regular posts WordPress returns a 301 and redirects to the actual post URL, which is what I would have expected. Anyone know what is different about media? This is happening on a site where a lot is going on but I also tried it on super basic WP install in a test environment. Permalink structure is set to:
Is this permalink setting part of the problem?