Welcome to WebmasterWorld Guest from 54.221.131.67

Forum Moderators: goodroi

Message Too Old, No Replies

Disallow images with suffix

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

Junior Member

10+ Year Member

joined:Aug 7, 2007
posts: 188
votes: 0


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.
12:06 pm on Jan 13, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10646
votes: 630


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:
12:12 pm on Jan 13, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 7, 2007
posts: 188
votes: 0


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
12:28 pm on Jan 13, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10646
votes: 630


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.)