Redirect Image Attachment URLs
Attachments to posts are stored in the database as posts, this means they’re accessible under their own URLs. Enabling the redirect image feature will redirect these URLs to the actual image.
Redirect attachment URLs to the actual image
- 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’.
- The ‘SEO’ settings will expand providing you additional options. Click on ‘Search Appearance’.
- Click on the ‘Media’ tab.
- Toggle the ‘Redirect attachment URLs to the attachment itself?’. Yes will automatically redirect the attachment URLs to the image itself. No redirect will leave the attachment URLs accessible.
What is an attachment URL?
Let’s say you upload an image called
image.png. WordPress uses the permalink structure to create a URL of
https://example.com/image/, for example. This page displays your theme header, sidebar, and footer with the embedded image. In most cases, you or your developer have not customized this page so it has little to no SEO value due to its thin content. For that reason, we recommend redirecting the URL to the actual image. Starting in Yoast SEO 7.0, we updated our media redirect feature as previous versions could fail to redirect in some cases.
Redirect attachment URLs to a post or page
Versions earlier than Yoast SEO 7.0 offered the option to redirect to a post or page. This method, however, was not always reliable and caused a lot of issues, especially when an image was added to multiple parts of your site. Therefore, the option was updated to redirect to the actual image.