You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Coughlin, Michael J" <Mi...@opm.gov> on 2013/02/24 04:28:24 UTC

[users@httpd] rewritecond problem

I have a RewriteCond issue:



I have a URI: /II/anydirectory/anyfile



I can get an exact match:



RewriteCond %{REQUEST_URI} ^/II/([^/]+)/(.+)$



So if I want the /II part to be optional in the match:

RewriteCond %{REQUEST_URI} ^(/II)?/([^/]+)/(.+)$



Now any thing can get through, since the /II part is optional, it seems to be taken out of the equation and I am left with the equivalent of:



^/([^/]+)/(.+)$



Of course /II/anyfile now matches, not the required /II/anydirectory/anyfile



So why is the fact that (/II)? IS in the URI, but not considered now as part of the overall match?  Is this just a rule of optional groupings that they will get ignored in the match?



Thanks



Re: [users@httpd] rewritecond problem

Posted by Eric Covener <co...@gmail.com>.
> consider, that / must be escaped ...

They don't need to be escaped.

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


Re: [users@httpd] rewritecond problem

Posted by "Walter H." <Wa...@mathemainzel.info>.
Hello,

consider, that / must be escaped ...

Walter



Re: [users@httpd] rewritecond problem

Posted by Eric Covener <co...@gmail.com>.
On Sun, Feb 24, 2013 at 11:28 AM, Coughlin, Michael J
<Mi...@opm.gov> wrote:
> Yes agree which is why I ask if it IS in the URL, which it is, and there is
> 1 match, not zero, it works as if there is zero mathching, because it it
> being ingored, but should not be.  So I ask if the nature of the optional
> match is to just ignore it anyways even if it does match.  I hope I am
> explaining correctly.

PCRE does whatever it takes to result in a match, which includes not
using up the /II when it would result in a non-match.

You need to express that extra requirement explicitly.

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


RE: [users@httpd] rewritecond problem

Posted by "Coughlin, Michael J" <Mi...@opm.gov>.
Yes agree which is why I ask if it IS in the URL, which it is, and there is 1 match, not zero, it works as if there is zero mathching, because it it being ingored, but should not be.  So I ask if the nature of the optional match is to just ignore it anyways even if it does match.  I hope I am explaining correctly.

________________________________
From: Igor Cicimov [icicimov@gmail.com]
Sent: Saturday, February 23, 2013 10:36 PM
To: users
Subject: Re: [users@httpd] rewritecond problem


On 24/02/2013 2:29 PM, "Coughlin, Michael J" <Mi...@opm.gov>> wrote:
>
> I have a RewriteCond issue:
>
>
>
> I have a URI: /II/anydirectory/anyfile
>
>
>
> I can get an exact match:
>
>
>
> RewriteCond %{REQUEST_URI} ^/II/([^/]+)/(.+)$
>
>
>
> So if I want the /II part to be optional in the match:
>
> RewriteCond %{REQUEST_URI} ^(/II)?/([^/]+)/(.+)$
>
>
>
> Now any thing can get through, since the /II part is optional, it seems to be taken out of the equation and I am left with the equivalent of:
>
>
>
> ^/([^/]+)/(.+)$
>
>
>
> Of course /II/anyfile now matches, not the required /II/anydirectory/anyfile
>
>
>
> So why is the fact that (/II)?
The ? means zero or one of II which means when not present matches anything really do you agree??

IS in the URI, but not considered now as part of the overall match?  Is this just a rule of optional groupings that they will get ignored in the match?
>
>
>
> Thanks
>
>

Re: [users@httpd] rewritecond problem

Posted by Igor Cicimov <ic...@gmail.com>.
On 24/02/2013 2:29 PM, "Coughlin, Michael J" <Mi...@opm.gov>
wrote:
>
> I have a RewriteCond issue:
>
>
>
> I have a URI: /II/anydirectory/anyfile
>
>
>
> I can get an exact match:
>
>
>
> RewriteCond %{REQUEST_URI} ^/II/([^/]+)/(.+)$
>
>
>
> So if I want the /II part to be optional in the match:
>
> RewriteCond %{REQUEST_URI} ^(/II)?/([^/]+)/(.+)$
>
>
>
> Now any thing can get through, since the /II part is optional, it seems
to be taken out of the equation and I am left with the equivalent of:
>
>
>
> ^/([^/]+)/(.+)$
>
>
>
> Of course /II/anyfile now matches, not the required
/II/anydirectory/anyfile
>
>
>
> So why is the fact that (/II)?
The ? means zero or one of II which means when not present matches anything
really do you agree??

IS in the URI, but not considered now as part of the overall match?  Is
this just a rule of optional groupings that they will get ignored in the
match?
>
>
>
> Thanks
>
>