以下是雅虎Search Blog发表的官方声明和robots.txt通配符解决方案:
Yahoo! Search Crawler (Yahoo! Slurp) – Supporting wildcards in robots.txt
I was going through my notes from Danny Sullivan’s Open Feedback sessions that occur during the ?Meet the Crawlers? panel at Search Engine Strategies. One of the items on my list was a request for enhanced syntax in robots.txt to make it easier for webmasters to manage how search crawlers, including Slurp, access your content.
For those who may not be as familiar with search index terminology, webmasters use the robots.txt file to direct robots that visit their site, including search engine crawlers, which files should be crawled and which shouldn’t be. You can read about our support for robots directives in the help for Yahoo! Slurp.
Well, we can scratch that one off the list, since we have just updated Yahoo! Slurp to recognize two additional symbols in the robots.txt directives ? ‘*’ and ‘$’. The semantics of these is what is as widely understood for robots.txt files.
‘*’ – matches a sequence of characters
You can now use ‘*’ in robots directives for Yahoo! Slurp to wildcard match a sequence of characters in your URL. You can use this symbol in any part of the URL string you provide in the robots directive. For example,
User-Agent: Yahoo! Slurp
Allow: /public*/ #允许所有以public开头的目录被索引
Disallow: /*_print*.html
Disallow: /*?sessionid #这句的意思是拒绝一切包含sessionid参数的页面被搜索引擎索引。
The robots directives above will:
allow all directories that begin with ‘public’, such as ‘/public_html/’ or ‘/public_graphs/’ to be crawled
disallow any files or directories which contain ‘_print’, such as ‘/card_print.html’ or ‘/store_print/product.html’ to be crawled
disallow any files with ‘?sessionid’ in their URL string, such as ‘/cart.php?sessionid=342bca31? to be crawled
Note that a trailing ‘*’ is redundant since that is existing matching behavior for Slurp. So, the following two directives are equivalent:
User-Agent: Yahoo! Slurp
Disallow: /private*
Disallow: /private
‘$’ ? anchors at the end of the URL string
You can now also use ‘$’ in robots directives for Slurp to anchor the match to the end of the URL string. Without this symbol, Yahoo! Slurp would match all URLs against the directives, treating the directives as a prefix. For example:
User-Agent: Yahoo! Slurp
Disallow: /*.gif$
Allow: /*?$
The robots directives above will
Disallow all files ending in ‘.gif’ in your entire site. Note that without the ‘$’, this would disallow all files containing ‘.gif’ in their file path
Allow all files ending in ‘?’ to be included. This would not automatically allow files that just contain ‘?’ somewhere in the URL string
As you can see, this symbol only makes sense at the end of the string. Hence, when we see it, we assume that your directive terminates there and any characters after that symbol are ignored.
Oh, by the way, if you thought we didn’t support the ‘Allow’ tag, as you can see from these examples, we do.
If you have any questions about the new syntax or any particular cases you are concerned about, please write in at the Site Explorer forums or read up our area.
Next time you see me at SES, you should ask me what else is on my list!
Priyank Garg
Product Manager, Yahoo! Search
可以用google管理员工具测试,一般第一次提交很快就会抓取robots.txt,然后更新就慢了点