How to make WordPress Media Files No-Index and Redirect Attachment Pages to Primary Post
Please Subscribe to our YouTube Channel
WordPress usually keep saving the attachment as a separate post in the database. So Google can index those pages and drive traffic to them. So it may sound beneficial, but it could be very harmful if you don’t know what you are really doing. If you are running wallpaper site, then you will really want people to visit attachment page instead of the media file directly. So this is something you want to happen. However, if you have written an article about a game, smartphone or anything else and Google Indexes the attachment page, then it will create a duplicate content issue because the URL for the attachment pages are usually the same along with additional URL (filename) in the end. So it could be harmful to SEO/Search Ranking. This issue can be fixed easily and we will tell you how.
What is a solution if attachment pages are getting indexed?
You can create 301 redirects that will redirect all traffic from attachment page to primary post. The attachment page will gradually get de-indexed from Google.
How to redirect all traffic from Attachment Page to Primary Post?
- Install Yoast SEO Plugin if you don’t already have it installed. This WordPress Plugin has many great features even in the free version
- Now make sure Advanced Feature is enabled. You can do it by clicking SEO option (located on the sidebar under Admin Panel). Click on Dashboard option, and then select Features tab, now enable Advanced Settings Pages. Save the settings
- Some new options will be enabled Under SEO option on the sidebar. Click on Advanced option, select Permalinks tab, and then you will see some options. Under Redirect Attachment URLs to Parent Post URL, select Redirect option
- Save the setting and it’s done. Now clear cache of the website, and you can try visiting any attachment page, it will redirect to the primary post
How to Make Media Files No-Index on WordPress?
Please note that this option will stop showing images from your website even in Google Image Search, and other media files will not be indexed as well. So if you are sure you really want to do it, follow these steps;
- You will still need to install Yoast SEO Plugin as well explained above and enable the Advanced feature. Follow the steps we explained above to enable advanced feature
- Now click on Titles & Metas option
- Select Post Types tab
- Under the Media section select NoIndex option