我想禁止特定网址中的所有参数。
如果我添加这条规则:
Disallow: /*?*
它适用于所有 url
我想做什么:
Disallow: /my-specific-url/*?*
但根据 Google 网站管理员工具,此规则不起作用。
最佳答案
您的示例看起来应该可以正常工作,但您确实需要包含 User-agent 行。以下 robots.txt 文件:
User-agent: *
Disallow: /my-specific-url/*?*
将阻止以下 URL:
http://example.com/my-specific-url/?
http://example.com/my-specific-url/?a=b
但它不会阻止以下内容:
http://example.com/my-specific-url/
http://example.com/some-other-url/?a=b
请注意,尾随 * 是无害的,但没有任何用处。做完全相同的事情的更简洁的方法是:
User-agent: *
Disallow: /my-specific-url/*?
另请注意,主要搜索引擎支持通配符,但许多其他爬虫不支持通配符。
关于seo - 禁止 robots.txt 中特定 url 中的所有参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248558/