0

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?

1 Answer 1

1

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>
2
  • 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, 2012 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. Mar 6, 2012 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .