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?

Niro
  • 1,401
  • 4
  • 20
  • 36

1 Answers1

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>
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • 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 06 '12 at 08: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 06 '12 at 16:55