You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mohit Chawla <mo...@gmail.com> on 2016/07/29 10:47:16 UTC

[users@httpd] Using SetEnvIf for query string

Hi,

I am trying to use SetEnvIf with QUERY_STRING, but can't get it to work.
This is being done inside the mod_deflate module block like:

<IfModule mod_deflate.c>
SetEnvIf QUERY_STRING "baz" var=bar
LogFormat '"%q" "%{var}e"'
</IfModule>

...with a request like curl localhost?baz, the log has:
"?baz" "-"

Other variables like REQUEST_METHOD work fine:
<IfModule mod_deflate.c>
SetEnvIf REQUEST_METHOD GET var=bar
LogFormat '"%q" "%{var}e"'
</IfModule>
$ curl localhost?baz
"?baz" "bar"

Apache version is 2.2.22 on Ubuntu 12.04.

Any ideas how to debug or fix this ?

Thanks,

Re: [users@httpd] Using SetEnvIf for query string

Posted by Mohit Chawla <mo...@gmail.com>.
Thanks Yann, that worked perfectly !

On Fri, Jul 29, 2016 at 1:24 PM, Yann Ylavic <yl...@gmail.com> wrote:

> On Fri, Jul 29, 2016 at 12:47 PM, Mohit Chawla
> <mo...@gmail.com> wrote:
> > Hi,
> >
> > I am trying to use SetEnvIf with QUERY_STRING, but can't get it to work.
>
> The QUERY_STRING variable is not recognized by SetEnvif (see [1] for
> the list), hence it is considered a header name.
>
> You may want to use mod_rewrite's RewriteCond/RewriteRule instead ([2]),
> e.g.:
>   RewriteCond "%{QUERY_STRING}" "baz"
>   RewriteRule ^ - [E=var:bar]
>
> Regards,
> Yann.
>
> [1] https://httpd.apache.org/docs/2.2/mod/mod_setenvif.html#setenvif
> [2] http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Using SetEnvIf for query string

Posted by Yann Ylavic <yl...@gmail.com>.
On Fri, Jul 29, 2016 at 12:47 PM, Mohit Chawla
<mo...@gmail.com> wrote:
> Hi,
>
> I am trying to use SetEnvIf with QUERY_STRING, but can't get it to work.

The QUERY_STRING variable is not recognized by SetEnvif (see [1] for
the list), hence it is considered a header name.

You may want to use mod_rewrite's RewriteCond/RewriteRule instead ([2]), e.g.:
  RewriteCond "%{QUERY_STRING}" "baz"
  RewriteRule ^ - [E=var:bar]

Regards,
Yann.

[1] https://httpd.apache.org/docs/2.2/mod/mod_setenvif.html#setenvif
[2] http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org