logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: SetEnvIf troubles in .htaccess
Author
geoB



Joined: 16 Nov 2010
Posts: 2

PostPosted: Tue 16 Nov '10 6:08    Post subject: SetEnvIf troubles in .htaccess Reply with quote

With Apache 2.2 running on Win7 Pro 32-bit as a development environment.

In an otherwise properly running development site I'm experimenting with
Code:
SetEnvIf Remote_Addr 127.0.0.1 LOCALHOST

<IfDefine !LOCALHOST>
foo
</IfDefine>
My expectation is that, because I'm accessing the site on my box from my box, the variable LOCALHOST would be set. It is not - I get a 500 error. If there is no bogus text the the IfDefine block access is as expected. php reports REMOTE_ADDR as 127.0.0.1.

I admit my knowledge of apache is highly limited, but all I've read so far leads me to think that the variable should be set. I have at least confirmed that mod_setenvif is loaded. So obviously I'm missing something somewhere.

But what?

thanks.

g
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 16 Nov '10 9:42    Post subject: Reply with quote

uh no, not what IfDefine is for.

from http://httpd.apache.org/docs/2.2/mod/core.html#ifdefine

The parameter-name argument is a define as given on the httpd command line via -Dparameter- , at the time the server was started.

In 2.2, certain things allow you to use the environment to trigger, like logging, access, but not everything. And unfortunately there is no IfEnv.

# requests from localhost not logged.
SetEnvIf Remote_Addr 127.0.0.1 LOCALHOST
CustomLog logs/access_log common env=!LOCALHOST

# Allow access unless from certain countries with mod_geoip or by IP
SetEnvIf GEOIP_COUNTRY_CODE US BLACKLIST="BLACKLIST"
SetEnvIf Remote_Addr xxx.xxx.xxx.xxx BLACKLIST

Order Allow,Deny
Allow from all
Deny from env=BLACKLIST
Back to top
geoB



Joined: 16 Nov 2010
Posts: 2

PostPosted: Tue 16 Nov '10 15:32    Post subject: Reply with quote

ah, the trouble ignorance can cause. Thanks for filling me in. I won't try this. I've got enough other things to break; I think I'll leave this alone.

g
Back to top


Reply to topic   Topic: SetEnvIf troubles in .htaccess View previous topic :: View next topic
Post new topic   Forum Index -> Apache