Apache SetEnvIf trouble

北战南征 提交于 2019-12-10 17:07:01

问题


I have the following in my .htaccess file:

SetEnvIf Host "^example\.com$" myvar=1
<IfDefine myvar>
  RewriteRule ^(.*)$ index2.php?q=$1 [L,QSA]
</IfDefine>

As far as I can tell, this should be working properly. However, "myvar" does not appear to get defined when I visit from example.com. I know that I have the mod_setenvif.c enabled (I've verified with an <IfModule> block).

Any ideas why "myvar" isn't getting defined?


回答1:


This is really a ServerFault question, but anyway: IfDefine doesn't test environment variables, it tests the configuration options that were passed to Apache at startup. So for example, if you ran

apache2 -D MYVAR

then a section

<IfDefine MYVAR>
    ...
</IfDefine>

would get executed.

I'm not sure if there's any Apache configuration directive that acts as a conditional for environment variables, like you're looking for.



来源:https://stackoverflow.com/questions/1369023/apache-setenvif-trouble

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!