Forum Moderators: goodroi

Message Too Old, No Replies

Disallow images with suffix

         

terrybarnes

11:39 am on Jan 13, 2017 (gmt 0)

10+ Year Member



I have a WordPress site that adds images to the Uploads directory and so Google indexes that directory. That's fine and I want that to continue but is there any way of stopping Google indexing images with a certain suffix i.e. image-nosearch.jpg

I understand you can use this rule:

Disallow:/uploads/*.jpg

but can you use this rule:

Disallow:/uploads/*-nosearch.jpg

Thanks in advance for any help.

keyplyr

12:06 pm on Jan 13, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



AFAIK the inline wildcard (*) will only work at the end of the filename.

Example:
Disallow: /uploads/example*.jpg

Also, Google seems to be the only SE that recognizes inline wildcards in filenames for robots.txt.

Also, make sure to add a space after Disallow:

terrybarnes

12:12 pm on Jan 13, 2017 (gmt 0)

10+ Year Member



Thanks for this. So I could add a prefix e.g.

Disallow: /uploads/nosearch-*.jpg

and then block all other search engines from searching that directory e.g.

User-agent: yahoo
Disallow: /uploads

keyplyr

12:28 pm on Jan 13, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Should work :)

Google has a tool in GSC to test files against robots.txt. You'll need to update their copy first (also a feature at that tool.)