使用特定参数忽略robot.txt中的URL?

Lui*_*cia 66 seo robots.txt

我想谷歌忽略这样的网址:

http://www.mydomain.com/new-printers?dir=asc&order=price&p=3

所有具有参数dir,order和price的url都应该被忽略但我没有使用Robots.txt的经验.

任何的想法?

Boo*_*eus 118

如果您想禁止查询字符串,这是一个解决方案:

Disallow: /*?*
Run Code Online (Sandbox Code Playgroud)

或者如果您想更精确地查询字符串:

Disallow: /*?dir=*&order=*&p=*
Run Code Online (Sandbox Code Playgroud)

您还可以添加robots.txt以允许哪个网址

Allow: /new-printer$
Run Code Online (Sandbox Code Playgroud)

$将确保只/new-printer允许.

更多信息:

http://code.google.com/web/controlcrawlindex/docs/robots_txt.html

http://sanzon.wordpress.com/2008/04/29/advanced-usage-of-robotstxt-w-querystrings/

  • 根据http://www.robotstxt.org/robotstxt.html - "没有"允许"字段" (8认同)

Nic*_*ndo 24

您可以使用以下行阻止这些特定的查询字符串参数

Disallow: /*?*dir=
Disallow: /*?*order=
Disallow: /*?*p=
Run Code Online (Sandbox Code Playgroud)

因此,如果任何URL包含dir=,order=或在查询字符串中的p= 任何位置,它将被阻止.

  • 请注意:这也会阻止部分匹配表达式的参数,因此不仅会阻止“example.com?p=test”,还会阻止“example.com?top=test”。 (3认同)
  • 如果您想忽略这些参数,无论它们在 URL 中的位置(第一个位置或下一个位置),您可以尝试: `Disallow: /*?dir=* Disallow: /*?order=* Disallow: /*?p=*不允许: /*&dir=* 不允许: /*&order=* 不允许: /*&p=*` (3认同)