特定域的htaccess标头? [英] htaccess header for specific domain?

查看:71
本文介绍了特定域的htaccess标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三种环境:

env.com
env-uat.com
env-pre.com

所有三个页面都运行相同的代码。我希望env-uat.com和env-pre.com都可以在htaccess中获得它:

All three pages run the same code. I want env-uat.com and env-pre.com to both get this in the htaccess:

Header set X-Robots-Tag "noindex, nofollow"

这将有效地完全取消索引这些页面,包括PDF文件等。我不想影响env.com。

This will effectively completely unindex these pages, including PDF files etc. But I don't want to affect env.com.

如何使Header X-Robots-Tag仅添加到env-uat.com和env-pre .com而不是env.com?

How can I make the Header X-Robots-Tag only be added for env-uat.com and env-pre.com and NOT env.com?

**更新**

从到目前为止我能找到的东西,似乎您只能执行

From what I could find so far, it would seem you can only do something like this:

SetEnvIf Request_URI "^/privacy-policy" NOINDEXFOLLOW
Header set X-Robots-Tag "noindex, follow" env=REDIRECT_NOINDEXFOLLOW

但这使它特定于PAGE。我希望它特定于一个域。

But this makes it specific to a PAGE. I want it specific to a DOMAIN.

推荐答案

@Starkeen就在这里:

@Starkeen was right up to here :

SetEnvIf host ^(env-uat\.com|host2\.com)$ NOINDEXFOLLOW

因此,您可以这样包含要加入此Env的域:

So , you could include the domains that you want to be involved in this Env like this :

SetEnvIf host ^(env-uat|env-pre)\.com NOINDEXFOLLOW

然后,您应该使用以下相同名称附加Env:

Then you should attach the Env with same name like this :

Header set X-Robots-Tag "noindex, follow" env=NOINDEXFOLLOW

不是这样的:

Header set X-Robots-Tag "noindex, follow" env=REDIRECT_NOINDEXFOLLOW

上面的行将转到Env,其名称为REDIRECT_NOINDEXFOLLOW而不是NOINDEXFOLLOW,并且与该问题的情况不同 X机器人代码无索引规范fic页面
这是针对Request_URI和特殊情况的匹配。

The line above will look to Env its name is REDIRECT_NOINDEXFOLLOW not NOINDEXFOLLOW and it is diffrent case from this question X Robots Tag noindex specific page That was about matching against Request_URI and for special case .

因此,代码应如下所示:

So , the code should look like this :

SetEnvIf host ^(env-uat|env-pre)\.com NOINDEXFOLLOW
Header set X-Robots-Tag "noindex, follow" env=NOINDEXFOLLOW

这篇关于特定域的htaccess标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆