I don't think there's such a way to do it in robots.txt and also whatever is advertised in robots.txt is also what can be advertised to hackers because robots.txt is a file accessible to all.
What I would suggest is to use your scripting language to detect for the query string you don't want people to access and if the query string matches, create a redirect to a relevant page people are allowed to access or take them to a page with a 410 HTTP code.
For example, in PHP, you can use either of these to block the b=9
parameter from being accessible:
<?php
if ($_GET['b']=="9"){
header("HTTP/1.1 410 Gone",true);
echo "This page is gone.";
exit();
}
?>
<?php
if ($_GET['b']=="9"){
header("HTTP/1.1 301 Redirect",true);
header("Location: http://example.com/newpage",true);
echo "This page moved <a href=\"http://example.com/newpage\">here</a>";
exit();
}
?>
If you are looking to specifically block just robots and not real users, then you could make the parameters accessible via POST only. Here's the HTML and PHP you can use:
Html:
<form action="phpscript.php" method="POST">
<input type="hidden" name="b" value="9">
<input type="submit" value="special page">
</form>
Php file named phpscript.php:
<?php
if ($_GET['b']=="9" && strtoupper($_SERVER['REQUEST_METHOD']) != "POST"){
header("HTTP/1.1 410 Gone",true);
echo "This page is gone";
exit();
}
?>
Only problem with the post method is that making post requests are generally non-cacheable based requests since they're primarily meant for user data submission.
/shopping/books/?b=9
or all/shopping/books/
? Do you have rewrite rules on this folder ? more info there stackoverflow.com/questions/9149782/…