iis.htaccessisapi-rewrite

Can I do an if/then/else in htaccess?


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.

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:

if subdomain = 'abc' use this htpassword file

if subdomain = 'def' use this htpassword file

Can this be done?


Solution

  • Try something like this:

    SetEnvIf Host ^abc\. HOST_ABC
    SetEnvIf Host ^dev\. HOST_DEF
    
    <IfDefine HOST_ABC>
        AuthUserFile …
    </IfDefine>
    <IfDefine HOST_DEF>
        AuthUserFile …
    </IfDefine>