Forum Moderators: phranque

Message Too Old, No Replies

negative SetEnvIf conditional

         

powerflash

6:35 pm on Dec 12, 2014 (gmt 0)

10+ Year Member



I use these directives for check specific remote ip address


SetEnvIf Remote_Addr myipaddress trace_this_client


is possible use SetEnvIf in negative for invert conditional?

wilderness

7:37 pm on Dec 12, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



is possible use SetEnvIf in negative for invert conditional?


SetEnvIf Remote_Addr myipaddress trace_this_client/


I don't quite understand your example (maybe I'm just having a dense moment), however not in the manner of your example.

The answer is yes!

SetEnvIf Remote_Addr ^123\.456\. !keep_out

The leading exclamation point at the front of your own same phrase does what you wish.

lucy24

7:54 pm on Dec 12, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



is possible use SetEnvIf in negative for invert conditional?

Are you asking about the third element, as in
SetEnvIf variable-type desired-value
SetEnvIf variable-type !unwanted-value
? No. The docs [httpd.apache.org] don't say so explicitly, so I experimented. A ! in this position is interpreted as a literal exclamation mark, which is rare but not impossible in a request.

The ! can be used to remove a previously set environmental variable, as in
SetEnvIf Remote_Addr ^128\.30\.52 !keep_out

(a line I personally use. It means "let the link checker run wild even though they use a stupid UA") but I don't think that's what you were asking.

powerflash

10:40 pm on Dec 12, 2014 (gmt 0)

10+ Year Member



I use in this context

ExtFilterDefine fixtext1 mode=output intype=text/html cmd="/bin/sed s/findstring/replacestring/g" EnableEnv=trace_this_client

SetEnvIf Remote_Addr myipaddress trace_this_client
SetOutputFilter fixtext1


I want that replace sed cmd run for all ip address unless myipaddress

lucy24

1:58 am on Dec 13, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do it the other way around. First set the environmental variable globally, and then say
SetEnvIf Remote_Addr myipaddress !trace_this_client

which wipes the variable.

But can't you use a ! negative in the EnableEnv statement instead?

:: detour to docs, because I'm not familiar with the syntax of this command ::

Hey, I was close. You need to switch it around and use disableenv instead of enableenv. The SetEnvIf part then becomes something like
SetEnvIf Remote_Addr myipaddress ignore_this_client

powerflash

9:39 am on Dec 13, 2014 (gmt 0)

10+ Year Member



I tried this but not work

ExtFilterDefine fixtext1 mode=output intype=text/html cmd="/bin/sed s/findstring/replacestring/g" EnableEnv=trace_this_client

<Location />
SetEnvIf Remote_Addr "^" loopback_ip=1
SetEnvIf Remote_Addr myipaddress loopback_ip=2
SetEnvIf loopback_ip 1 trace_this_client
SetOutputFilter fixtext1
</Location>

powerflash

10:22 am on Dec 13, 2014 (gmt 0)

10+ Year Member



I solved with different solution based on host name

ExtFilterDefine fixtext1 mode=output intype=text/html cmd="/bin/sed s/findstring/replacestring/g" EnableEnv=trace_this_client

SetEnvIf Host parking\.hostname\.com trace_this_client
SetOutputFilter fixtext1


with this solution I use main hostname and others use a parking domain

lucy24

9:28 pm on Dec 13, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I solved with different solution

Well, that's definitely cleaner than the previous version. But why do you need to use EnableEnv? DisableEnv would seem to be what the situation warrants ("do this for everyone except such-and-such").