How to set X-Robots-Tag in htaccess for any query string

It is just a note for me to remember this trick:

RewriteCond %{QUERY_STRING} .
RewriteRule .* - [E=MY_SET_HEADER:1] [QSD,R=302,L]
Header set X-Robots-Tag "noindex, nofollow" env=MY_SET_HEADER

It is based on the suggestion here but with a change to support if there is any query string in the URL.

Liked it? Take a second to support Mte90 on Patreon!
Become a patron at Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *