我可以做一个的if / then / else语句htaccess的?做一个、语句、if、then

2023-09-02 00:27:47 作者:套路撩人

我有一个网站,提供了基于子域的特定内容。因此,它是一组相同的文件,也许头和基于子域名的网站的网页更改的一些信息。

I have a site that serves up certain content based on the subdomain. So it is the same set of files, and maybe the header and some info in the site pages changes based on the subdomain.

我需要根据子域也有不同的htpassword身份验证,但无法找到如何做一个信息的if / then事情在htaccess的类型。

I need to have different htpassword authentication based on the subdomain as well, but can't find info on how to do an if/then type of thing in htaccess .

基本上,我需要的是这样的:

Basically what I need is this:

如果子域='ABC' 使用此htpassword文件

if subdomain = 'abc' use this htpassword file

如果子域='高清' 使用此htpassword文件

if subdomain = 'def' use this htpassword file

可以这样做?

推荐答案

尝试是这样的:

SetEnvIf Host ^abc. HOST_ABC
SetEnvIf Host ^dev. HOST_DEF

<IfDefine HOST_ABC>
    AuthUserFile …
</IfDefine>
<IfDefine HOST_DEF>
    AuthUserFile …
</IfDefine>