Re: reqrep always replaces, even when position \x is not found?

From: Pedro Mata-Mouros Fonseca <pedro.matamouros#sapo.pt>
Date: Mon, 24 Aug 2009 12:10:41 +0100


Greetings,

Sorry for the "double" posting, let me just try to simplify the exposition of the problem. I'm trying to rewrite a URI using regular expression placeholders, but I'm having a problem that when a placeholder doesn't match anything it still gets replaced in the destination with a '1'. This is the configuration directive (basically if the URI is rss2, rewrite to RSS2; but if it is rss only, rewrite to RSS): reqrep ^([^\ ]*)\ /rss(2*)(.*) \1\ /Endpoint/RSS\2\3

Calling rss2 correctly rewrites the URI: => /rss2?u=username correctly rewrites to /Endpoint/RSS2?u=username

However calling rss (without the '2') triggers a wrong replacement: => /rss?u=username incorrectly rewrites to /Endpoint/RSS1?u=username, instead of /Endpoint/RSS?u=username

This is the content of the log:
10.134.15.124 - - [21/Aug/2009:12:08:33 +0100] "GET /Endpoint/RSS2? u=username HTTP/1.1" 404 209
10.134.15.124 - - [21/Aug/2009:12:09:05 +0100] "GET /Endpoint/RSS1? u=username HTTP/1.1" 404 209

Many thanks again.

Pedro.

On Aug 21, 2009, at 12:19 PM, Pedro Mata-Mouros Fonseca wrote:

> Greetings,
>
> I'm using a reqrep to search in a URI for either the "rss" or "rss2"
> strings. The objective is to have the following mapping:
> /rss?u=username => /Endpoint/RSS?u=username
> /rss2?u=username => /Endpoint/RSS2?u=username
>
> This is the reqrep I'm using:
> reqrep ^([^\ ]*)\ /rss(2*)(.*) \1\ /Endpoint/RSS\2\3
>
> This is the result:
> 10.134.15.124 - - [21/Aug/2009:12:08:33 +0100] "GET /Endpoint/RSS2?
> u=username HTTP/1.1" 404 209
> 10.134.15.124 - - [21/Aug/2009:12:09:05 +0100] "GET /Endpoint/RSS1?
> u=username HTTP/1.1" 404 209
>
> When \2 exists, it is replaced accordingly, but when it doesn't a 1
> is used for replacement, instead of an empty string... Any ideas of
> what could be happening?
>
> (Note that each return a 404, because there's not really any content
> - this was just to test the regexp replacement.)
>
> Thanks so much.
>
> Pedro.
>
>
Received on 2009/08/24 13:10

This archive was generated by hypermail 2.2.0 : 2009/08/24 13:15 CEST