我需要为模块设置一个参数
(具体是通过设置一个参数GeoIPEnable On来激活geoencoding模块)
在httpd.conf中基于请求url中的参数(例如geo = true)。
如何才能做到这一点?
这样做的“好”方法就是Apache 2.4中的<If>function。
假设没有,你只剩下相当黑客的解决方法。 假设这些内容可以正常使用(如果你有dynamic内容,这可能会中断 – 你可以扩展Apache内部运行的内容吗?),你可以沿着这些方向做些事情:
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>