2 added 237 characters in body
source | link

Since all the subdomains point to the same place on the filesystem then you can do something like the following at the top of your .htaccess file in the document root:

SetEnvIf Host ^docs\. INDEX
SetEnvIf Host ^foo\. INDEX
Header set X-Robots-Tag "noindex, nofollow" env=!INDEX

This uses mod_setenvif to conditionally set an environment variable INDEX for the subdomains you wish to allow indexing, ie. that you do not want to set the X-Robots-Tag header. The subdomains are identified by checking the Host HTTP request header. The noindex X-Robots-Tag header is then only set if this environment variable is not set.

Note that this will currently set the noindex X-Robots-Tag on the domain apex (ie. example.com) and www subdomains as well. To exclude the main domain then add another exception:

SetEnvIf Host ^(www\.)?example\.com INDEX

Since all the subdomains point to the same place on the filesystem then you can do something like the following at the top of your .htaccess file in the document root:

SetEnvIf Host ^docs\. INDEX
SetEnvIf Host ^foo\. INDEX
Header set X-Robots-Tag "noindex, nofollow" env=!INDEX

This uses mod_setenvif to conditionally set an environment variable INDEX for the subdomains you wish to allow indexing, ie. that you do not want to set the X-Robots-Tag header. The subdomains are identified by checking the Host HTTP request header. The noindex X-Robots-Tag header is then only set if this environment variable is not set.

Since all the subdomains point to the same place on the filesystem then you can do something like the following at the top of your .htaccess file in the document root:

SetEnvIf Host ^docs\. INDEX
SetEnvIf Host ^foo\. INDEX
Header set X-Robots-Tag "noindex, nofollow" env=!INDEX

This uses mod_setenvif to conditionally set an environment variable INDEX for the subdomains you wish to allow indexing, ie. that you do not want to set the X-Robots-Tag header. The subdomains are identified by checking the Host HTTP request header. The noindex X-Robots-Tag header is then only set if this environment variable is not set.

Note that this will currently set the noindex X-Robots-Tag on the domain apex (ie. example.com) and www subdomains as well. To exclude the main domain then add another exception:

SetEnvIf Host ^(www\.)?example\.com INDEX
1
source | link

Since all the subdomains point to the same place on the filesystem then you can do something like the following at the top of your .htaccess file in the document root:

SetEnvIf Host ^docs\. INDEX
SetEnvIf Host ^foo\. INDEX
Header set X-Robots-Tag "noindex, nofollow" env=!INDEX

This uses mod_setenvif to conditionally set an environment variable INDEX for the subdomains you wish to allow indexing, ie. that you do not want to set the X-Robots-Tag header. The subdomains are identified by checking the Host HTTP request header. The noindex X-Robots-Tag header is then only set if this environment variable is not set.