Skip to content

WordPress Attachment Pages: Check the URL Before Redirecting

Distinguish an attachment page, the media file and the article. Verify WordPress or plugin redirects without breaking the image.

The same potted herb photo as a small print, a single-image mount and an article illustration
Jack Lee
3 Min Read
Share
On This Page

A WordPress attachment page is a web page for a media item. The image file and an article that embeds it have their own URLs. If a thin attachment page is appearing in search, identify the exact URL and its current response before choosing a redirect.

Separate the attachment, media file and article

In a worked example, a nursery publishes a guide to growing basil in a pot. The same photo also has a WordPress attachment page. Check which URL search actually shows and what it returns when opened while logged out.

URL in the exampleWhat it should identify
/?attachment_id=123The page request for the photo’s attachment record. A site can use a pretty permalink instead.
/wp-content/uploads/basil-pot.jpgThe image file that the guide and other pages can load.
/how-to-grow-basil/The article with the growing steps, the photo and its context.

Find what is handling the attachment URL

WordPress 6.4 disabled attachment pages by default for new installations. An installation upgraded from before 6.4 kept attachment pages enabled by default. If you maintain the site with WP-CLI, the read-only command wp option get wp_attachment_pages_enabled shows the core option. On WordPress 6.4 and later, a value of 0 disables attachment pages and core sends a valid attachment request to the file. A value of 1 enables the pages. An SEO plugin or server rule can still change the response a visitor receives.

In the browser Network panel, request the attachment URL with the log preserved. Record the attachment’s first status, each redirect destination and the final response type. Open the intended article and the direct file separately. The article should return an HTML page, and the file should return an image. The WordPress SEO settings guide covers the broader settings review.

Choose a useful destination and test it

If the attachment page has its own useful text and purpose, it can remain a page. For a thin attachment page whose visitors need the basil-growing instructions, consider a permanent redirect to that relevant article. If visitors just need the image, core’s file destination may be the right fit.

After changing a rule on staging, open the original attachment URL while logged out. Look for a single redirect to the chosen destination, then confirm the article still loads the image from the file URL. Check for a redirect chain or loop using the redirect and status code guide. Update internal links that still point to the attachment page.

Frequently asked questions

Do I need to delete the image from the Media Library?

No. The issue concerns which web page people can open. Keep the media file if your article or another page uses it.

Can I send all attachment pages to their parent articles?

Check whether each attachment has a relevant parent. Old uploads can be unattached or reused across multiple pages. Pick a destination that matches what a visitor needs.

Why does Google still show the old URL after a redirect?

Google may be using an older crawl. Verify the public redirect and inspect the original URL after Google has reprocessed it.

Share This Article