Setting X-Robots-Tag header on multiple queries and pathes via htaccess

297 Views Asked by At

I'm trying to set X-Robots-tag for some url parameters and specific path, simulatenously from htaccess.

I have google indexing urls such as

https://www.shantima.com/shop/large-waffle-linen-bath-towel/?wishlist-action
https://www.shantima.com/ru/shop/vafelnoe-lnyanoe-bannoe-polotence/?wishlist-action&lang=ru
https://www.shantima.com/ru/?taxonomy=product_shipping_class&term=0-5-1kg-ru/page/2/
https://www.shantima.com/wp-admin/admin-ajax.php?action=rest-nonce
https://www.shantima.com/ru/blog/tag/whomademyclothes/feed/

And obviously I don't like this at all... looking to set X-Robots-tag header on all of these variations of urls.

so what I currently have on my htaccess is this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ^taxonomy=([a-zA-Z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^term=([a-zA-Z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^action=([a-zA-Z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^lang=([a-zA-Z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^wishlist-action=([a-zA-Z0-9]*)$ [OR]
Rewritecond /feed/
RewriteRule .* - [E=NOINDEX_HEADER:1] 
</IfModule>
<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex" env=NOINDEX_HEADER
</IfModule>
# END WordPress

Now.. as you guessed, this is not working for non of the url variations, no queries and not the "feed" path...

Would love to have your suggestions on how to resolve this thing... Any idea how I can make this work?

Your help will be highly appreciated!

Cheers & Regards

J.o

0

There are 0 best solutions below