How Do I Redirect Image Attachment URLs?

Last update: 15 May, 2017

Attachments to posts are stored in the database as posts, this means they're accessible under their own URLs if you do not redirect them, enabling this will redirect them to the post they were attached to.

If the attachment URL is not redirecting or redirects to the wrong URL, the image is likely not attached to a post or page. Learn how to attach an image to a post or page below.

1
Log in to your WordPress website. When you're logged in, you will be in your 'Dashboard'. On the left-hand side, you will see a menu. In that menu, click on 'SEO'.
2
The ‘SEO’ settings will expand providing you additional options. If you don't see the 'Advanced' setting in your 'SEO' menu, please enable your advanced settings first.

Yoast SEO > Dashboard (Advanced disabled)

Menu with advanced settings disabled
Enable advanced features

3
Click on 'Advanced'.
Yoast SEO > Advanced
4
Click on the 'Permalinks' tab.
5
Toggle the 'Redirect attachment URLs to parent post URL'. Redirect will automatically redirect the attachment URLs to the parent post. No redirect will leave the attachment URLs accessible.Yoast SEO > Advanced > Permalinks > Redirect attachments

Why Is It Not Working?

This only works when an image is attached to a post. You can attach images to posts in the media section.

1
Log in to your WordPress website. When you're logged in, you will be in your 'Dashboard'. On the left-hand side, you will see a menu. In that menu, click on 'Media'.
2
Switch to list view by clicking the list icon.Admin > Media > List View
3
Change 'All media items' to 'Unattached' and click 'Filter'.
4
Hover your mouse over the first image. Click Attach and select post or page where you want this image's attachment URL to redirect. Repeat for all unattached images.

If an image is attached to the wrong page, you can click Detach when filtering for 'All media items' and attach to the correct page.

Was this article helpful? ·