让 .htaccess 根据域名要求输入密码

发布于 2024-08-11 11:15:22 字数 87 浏览 2 评论 0原文

我们有几个域名别名都指向同一服务器和目录(只是别名)。

但当人们来自某些域名时,我想用密码保护(htaccess)该网站。

谢谢

We have several domain name aliases all pointing to the same server and directory (just aliases).

But I'd like to password-protect (htaccess) the site when people come from certain domain names.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2024-08-18 11:15:22

您可以使用 SetEnvIf

SetEnvIfNoCase Host ^www\.example\.com$ host_a
SetEnvIfNoCase Host ^www\.example\.org$ host_b
SetEnvIfNoCase Host ^www\.example\.net$ host_c

<IfDefine host_a>
    …
</IfDefine>
<IfDefine host_b>
    …
</IfDefine>
<IfDefine host_c>
    …
</IfDefine>

You can do this using SetEnvIf and <IfDefine>:

SetEnvIfNoCase Host ^www\.example\.com$ host_a
SetEnvIfNoCase Host ^www\.example\.org$ host_b
SetEnvIfNoCase Host ^www\.example\.net$ host_c

<IfDefine host_a>
    …
</IfDefine>
<IfDefine host_b>
    …
</IfDefine>
<IfDefine host_c>
    …
</IfDefine>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文