I am facing an understanding issue with image accessibility on my WordPress website. Here’s the scenario:

  • My website URL is mysite.com.
  • I have a post titled “hello-world,” which is accessible at mysite.com/hello-world.
  • I recently uploaded an image called “earth” to my WordPress media library.
  • The image is be accessible at the URL mysite.com/uploads/year/month/earth.
  • However, I noticed that when I access mysite.com/hello-world/earth, the image is also available at that URL.

I am confused about why the image is accessible on the specific post URL. I expected it to be available only at the default media library URL. Can anyone shed some light on why this is happening and how I can resolve it?

I appreciate any insights or suggestions you may have regarding this issue. Thank you in advance for your help!

Best regards,


  • 1
    when you say the image is available do you mean the image file or a page that presents the image? It sounds like you've just discovered attachment pages for the first time
    – Tom J Nowell
    Commented Jan 11 at 19:42
  • Yes that's it, attachment pages. What is the reason for them? Is there any way to prevent them?
    – kocjs
    Commented Jan 12 at 2:30
  • 1
    Ok, since wordrpess 6.4 they are disabled by default, make.wordpress.org/core/2023/10/16/changes-to-attachment-pages. It is possible to disable them
    – kocjs
    Commented Jan 12 at 2:58

1 Answer 1


They aren't the same, one is the URL of the file in the uploads folder, the other is the permalink of the attachment post that represents that file. All uploaded files have attachment posts, that's what you're seeing listed in the media library. WordPress itself doesn't know about the files and can even show things that aren't in the uploads folder if you manually delete them.

Since most people are unaware of them and are confused when they first encounter them and think it's a bug, attachment templates/pages are disabled by default on new installs as of WP 6.4, and can be disabled for old sites:


TLDR: Set the wp_attachment_pages_enabled option to the value 0 to disable attachment pages.

One of the downsides is that most theme authors are unaware and ignore the audio.php/attachment.php/etc templates, or if they do handle them they display the file directly without any special handling, which implies duplication which spooks people concerned with SEO who see this for the first time and don't know about this.

Yes that's it, attachment pages. What is the reason for them? Is there any way to prevent them?

You could just display the attachment, but these pages give you opportunities to do other things such as:

  • password protections
  • displaying author/EXIF/location data
  • Comments!
  • sharing the attachment directly
  • custom templating
  • custom players such as video/PDF/audio

In the past I've used them so that when people click on gallery thumbnails in my posts they stay on my site and can click back and forwards, read more in depth captions, leave comments, etc. I also stripped down the template to show my header and highlight images.

  • The change in WordPress 6.4 does not work as suggested. It redirects to the upload folder, but only logged in users. core.trac.wordpress.org/ticket/59866
    – kocjs
    Commented Jan 13 at 15:36
  • If you like me, do not like attachment posts consider to 404 them instead of redirecting them to the upload folder. wordpress.stackexchange.com/questions/237762/…
    – kocjs
    Commented Jan 13 at 15:42
  • @kocjs that could have SEO consequences!! Removing the rewrite rule might give them a 404, but they'll still appear in sitemaps, the non-pretty URLs still work, and WP will still show those permalinks in REST API endpoints, and as options in the GUI for gallery links etc. The redirect is there so that existing links aren't broken. By using the option in 6.4 WP will be aware you don't want them and change the UI and its internal behaviour accordingly, if you don't want the redirect that's a good question to ask but that isn't the solution, it's just a band aid from before sitemaps/etc
    – Tom J Nowell
    Commented Jan 13 at 19:16
  • also note that when I wrote the answer I didn't realise any redirects occurred at all. If it 404s for logged out users isn't that what you already wanted?
    – Tom J Nowell
    Commented Jan 13 at 19:29
  • the new WordPress setting only redirects the post for logged in users, there is not change for regular visitors, they are not getting redirected.
    – kocjs
    Commented Jan 15 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.