• We have several attachment url’s getting indexed by Google.

    So we used the Yoast plugin and enabled the option: Send attachment URLs to parent post URL. This is Working correctly.

    After this Google was still indexing our attachment url’s.

    So for the unlinked media attachment files we decided to no-index, follow them (with the Yoast SEO tool to).

    But after we put this attachment url’s to no-index, follow, Google is still indexing new attachment pages every day now (with a no-index tag).

    Like example: muurstickerstunter.nl/?attachment_id=95

    What We should we do? Do we we need to redirect all unlinked media attachment to? I still find it strange google is indexing these attachment urls with a no-index tag.

Viewing 5 replies - 1 through 5 (of 5 total)
  • pressword1

    (@pressword1)

    Hi did you resolve the problem?

    Thread Starter muurstickerstunter

    (@muurstickerstunter)

    Hi pressword1

    We redirected all the linked-attachment urls to the parent post/pages url’s.

    All the unlinked media attachment’s are redirecting to the homepage.

    We are not using the function in de Yoast SEO plugin because is doesn’t redirect unlinked media. We wrote are own code for it in the functions.php. I wrote a (dutch) blog about the attachment url’s. If you have any questions about it let me know.

    add_action( 'template_redirect', 'attachment_redirect', 1 );
    	/**
    	 * Redirect any attachment page to their parent with 301 redirection
    	 */
    	function attachment_redirect() {
    		global $post;
    		if ( is_attachment() AND isset( $post->post_parent) AND is_numeric( $post->post_parent ) ) {
    			if( $post->post_parent !== 0 ):
    				wp_redirect( get_permalink( $post->post_parent ), 301 );
    			else:
    				wp_redirect( site_url(), 301 );
    			endif;
    			exit();
    		} elseif( isset($_GET['attachment_id']) ) {
    			wp_redirect( site_url(), 301 );
    		}
    
    	}
    Vicky

    (@vickymedrano)

    Hi guys,

    I have the same problem. YOAST Redirect attachment URL’s to parent post URL is not wroking at all and google is indexing my attachments even though I have it set to noindex. I’m going crazy.

    I’m gonna try your tweak muurstickerstunter.

    I’ll post back the feedback, thanks for sharing.

    Vicky

    (@vickymedrano)

    muurstickerstunter, your fix didn’t work for me, I got 500 server error =(

    I’ll keep looking for solutons…

    Thread Starter muurstickerstunter

    (@muurstickerstunter)

    Hi vickymedrano,

    The code should work, i’m going to recheck the code for you this weekend.

    You can try the following to: Open your webmaster console en go to:

    Crawl-Url Parameters. You can configure your attachment parameter up here.

    Choose edit – Select Yes …. – No Urls. You can hide your attachment content for the Google bot.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘No-index attachment URLS getting indexed’ is closed to new replies.