htaccess If…Else always selects Else

前端 未结 4 1795
温柔的废话
温柔的废话 2021-02-12 21:59

I set an environment variable in httpd-vhosts.conf

SetEnv EARLY_VAR 1

I try setting special rules based on its value in

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-12 22:31

    The only way I could make it work is using SetEnvIf both in .conf and .htaccess:

    I used only this in .conf

    SetEnvIf Server_Addr ^ EARLY_VAR=1
    

    and then only this in .htaccess :

    SetEnvIf EARLY_VAR ^ TEST_VAR=else_branch
    SetEnvIf EARLY_VAR ^1$ TEST_VAR=if_branch
    

    (without If directive. Whatever I tried within If, it seemed like it was evaluated before EARLY_VAR is set)

提交回复
热议问题