You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chaitanya Govande <ch...@gmail.com> on 2018/05/16 19:22:58 UTC
[users@httpd] IF request_uri regex syntax
Hello,
Trying to check the request uri against a regex in an IF directive.
This IF directive is located inside a <Location> tag.
Following is the code:
<If "%{REQUEST_URI} =~ /manager/status/ && %{HTTP_USER_AGENT} =~
/Chrome/ && %{QUERY_STRING} =~
/org.apache.catalina.filters.CSRF_NONCE=.*/">
AddOutputFilterByType INFLATE;SUBSTITUTE;DEFLATE text/html
</If>
However, when trying to restart apache, I get the following:
May 16 19:20:53 apache.localdomain systemd[1]: Starting The Apache
HTTP Server...
May 16 19:20:54 apache.localdomain httpd[2586]: AH00526: Syntax error
on line 21 of /etc/httpd/test/test.conf:
May 16 19:20:54 apache.localdomain httpd[2586]: Cannot parse condition
clause: syntax error, unexpected T_ID, expecting $end
May 16 19:20:54 apache.localdomain systemd[1]: httpd.service: main
process exited, code=exited, status=1/FAILURE
May 16 19:20:55 apache.localdomain kill[2588]: kill: cannot find process ""
May 16 19:20:55 apache.localdomain systemd[1]: httpd.service: control
process exited, code=exited status=1
May 16 19:20:55 apache.localdomain systemd[1]: Failed to start The
Apache HTTP Server.
May 16 19:20:55 apache.localdomain systemd[1]: Unit httpd.service
entered failed state.
May 16 19:20:55 apache.localdomain systemd[1]: httpd.service failed.
I can get it to work if I do a string compare (==) but I would like to
do it against a regex statement but just can't seem to figure out the
correct syntax.
Any help is appreciated.
Thank you,
Chaitanya Govande
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] IF request_uri regex syntax
Posted by Chaitanya Govande <ch...@gmail.com>.
Thank you very much - this seems to have did the trick. I appreciate it, Yann.
On Wed, May 16, 2018 at 2:38 PM, Yann Ylavic <yl...@gmail.com> wrote:
> On Wed, May 16, 2018 at 9:22 PM, Chaitanya Govande <ch...@gmail.com> wrote:
>>
>> Following is the code:
>>
>> <If "%{REQUEST_URI} =~ /manager/status/ ...
>
> The issue may be that '/' is both a regex separator and a path in this
> expression.
> The other form of regexes to work around this is "m<sep>regex<sep>",
> so you possibly could try something like "m#manager/status#" here.
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
--
Chaitanya Govande
847-387-0546
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] IF request_uri regex syntax
Posted by Yann Ylavic <yl...@gmail.com>.
On Wed, May 16, 2018 at 9:22 PM, Chaitanya Govande <ch...@gmail.com> wrote:
>
> Following is the code:
>
> <If "%{REQUEST_URI} =~ /manager/status/ ...
The issue may be that '/' is both a regex separator and a path in this
expression.
The other form of regexes to work around this is "m<sep>regex<sep>",
so you possibly could try something like "m#manager/status#" here.
Regards,
Yann.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org