I want to block a query string url's in .htaccess using x-robots tag. The url's are something like:
https://www.example.com/test?limit=60
https://www.example.com/test?limit=45
https://www.example.com/test?limit=all
I need to block the ?limit=xxx
Ive tried something like this but it doesnt work:
<IfModule mod_headers.c>
<Files "^limit=?$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>
</IfModule>
Got it working with this:
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ^limit=([a-zA-Z0-9]*)$
RewriteRule .* - [E=NOINDEX_HEADER:1]
</IfModule>
<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex" env=NOINDEX_HEADER
</IfModule>