Nathan H
Nathan H

Reputation: 49371

Have .htaccess ask for password depending on domain name

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

Upvotes: 2

Views: 552

Answers (1)

Gumbo
Gumbo

Reputation: 655239

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>

Upvotes: 2

Related Questions