Search code examples
seorobots.txt

Ignore URLs in robot.txt with specific parameters?


I would like Google to ignore URLs like this:

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

In other words, all the URLs that have the parameters dir, order and price should be ignored. How do I do so with robots.txt?


Solution

  • Here's a solutions if you want to disallow query strings:

    Disallow: /*?*
    

    or if you want to be more precise on your query string:

    Disallow: /*?dir=*&order=*&p=*
    

    You can also add to the robots.txt which url to allow

    Allow: /new-printer$
    

    The $ will make sure only the /new-printer will be allowed.

    More info:

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

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