Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need to set a param for a module

(specifically is activation of geoencoding module by setting a param GeoIPEnable On)

in httpd.conf based on a parameter in the request url (for example geo=true).

How can this be done?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The "good" way to do this would be the <If> functionality in Apache 2.4.

Assuming that's not available, you're left with rather hackish workarounds. Assuming the content will be ok with this (this may break if you have dynamic content - can you expand on what's running within Apache?), you could do something along these lines:

RewriteEngine On
# Do an internal redirect of the requests that have the geoip=true param:
RewriteCond %{QUERY_STRING} geoip=true [NC]
RewriteRule ^(.*)$ /geoip$1 [PT,QSA,L]

# Make the content under /geoip identical to the docroot:
Alias /geoip /path/to/docroot

# And, configure /geoip for the GeoIP lookups:
<Location /geoip>
    GeoIPEnable On
</Location>
share|improve this answer
    
Thanks for the answer. This is a very high traffic server so I dont want to turn rewrite engine on. Any other way to do it? –  Niro Mar 6 '12 at 8:31
    
Not without Apache 2.4 - and that's also a runtime evaluation, anyway. A single rewrite rule is a drop in the bucket of Apache's CPU load - I'd recommend testing the impact instead of ruling out mod_rewrite on principle. –  Shane Madden Mar 6 '12 at 16:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.