Mobile app version of vmapp.org
Login or Join
Cofer257

: Disable indexing of specific Images or based on size I am working on a project where I need to disable specific images from Google indexing, or disable based on their size. I do not have

@Cofer257

Posted in: #Images #Indexing #Noindex #Seo #Wordpress

I am working on a project where I need to disable specific images from Google indexing, or disable based on their size. I do not have any idea other than adding this code in robots.txt:

User-agent: Googlebot-Image
Disallow: /


As my platform is WordPress, all the images are in Upload folder. So I can't disable based on the folder either.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cofer257

1 Comments

Sorted by latest first Latest Oldest Best

 

@Annie201

What you can do is generate your images in a programming language with headers to stop indexing and then use some rewriterules to reference that image.

For example. Put this in your .htaccess:

RewriteRule ^(.*).jpeg$ /background.php?FILE= [L]


Then create the file background.php with this template:

<?php
$jpeg=imagecreatefromjpeg('/server-path/to/imagefolder/'.$_GET['FILE'].'.jpeg');
imagejpeg($jpeg,NULL,100);
imagedestroy($jpeg);
header('X-Robots-Tag: noindex, noimageindex',true);
header('Content-type: image/jpeg',true);
exit();
?>


Put .htaccess and background.php in document root folder. Now when you make a request to anything ending in .jpeg from your document root, it will try to find the jpeg file in the /server-path/to/imagefolder folder and then the program adds an extra header to direct search engines not to index that specific file.

If you want something super easy, then divide your images into separate folders and indicate the folder that is not to be indexed in robots.txt.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme