You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Garth Winter Webb <ga...@perijove.com> on 2003/02/16 20:22:33 UTC

[users@httpd] RewriteRule: Parenthesis not capturing

Hello, I'm trying to use the RewriteRule directive to rewrite a simple
request.  I've added these lines to a VirtualHost section of an apache
running on 'my.host' listening on port 80:

    RewriteEngine on

    RewriteLog      "/tmp/rewrite.log"
    RewriteLogLevel 9
    RewriteRule     ^/(.+) http://my.host:8600/somepath/$1 [P]

When I make a request like this:

    http://my.host/foo

I see these 5 lines in my rewrite log:


192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
[my.host/sid#80d18a4][rid#80e0794/initial] (2) init rewrite engine with
requested uri /foo
192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
[my.host/sid#80d18a4][rid#80e0794/initial] (3) applying pattern '^/(.*)'
to uri '/foo'
192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
[my.host/sid#80d18a4][rid#80e0794/initial] (2) rewrite /foo ->
http://my.host:8600/somepath/
192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
[my.host/sid#80d18a4][rid#80e0794/initial] (2) forcing proxy-throughput
with http://my.host:8600/somepath/
192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
[my.host/sid#80d18a4][rid#80e0794/initial] (1) go-ahead with proxy
request proxy:http://my.host:8600/somepath/ [OK]


For some reason the parenthesis are not capturing and $1 contains an
empty string.  The parenthesis HAD to match because otherwise the rule
("A '/' followed by at least one character") would have failed and I
would not have gotten these log messages.  What am I missing here?

Thanks,

-- 
Garth Winter Webb <ga...@perijove.com>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule: Parenthesis not capturing

Posted by Garth Winter Webb <ga...@perijove.com>.
On Sun, 2003-02-16 at 11:22, Garth Winter Webb wrote:

> 192.168.1.124 - - [16/Feb/2003:12:14:09 -0800]
> [my.host/sid#80d18a4][rid#80e0794/initial] (3) applying pattern '^/(.*)'
> to uri '/foo'

I'm sorry, this line was from a previous attempt when the RewriteRule
was '^/(.*)'.  This should be '^/(.+)'

-- 
Garth Winter Webb <ga...@perijove.com>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org