You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Joshua Slive <jo...@slive.ca> on 2003/02/10 00:22:26 UTC
Re: [users@httpd] Rewrite-problem
On Mon, 10 Feb 2003, Sander Holthaus - Orange XL wrote:
> RewriteRule ^([^?]*)\?(.*)$ <http://www.mydomain.com$1>
> http://www.mydomain.com$1
> [R,CO=querystring:$2:.mydomain.com]
> # put eveything without/until a ? in $1, put everything after a/the
> first ? in $2
> # $1 will be the redirect-uri
> # $2 will be written as a cookie
>
> The problem seems to the \? in the regex of the rewriterule. The regex
> will
> not match addresses with a ? in them.
RewriteRule matches only the URL-Path not including the query string. To
match the query string, you need to use a RewriteCond as in
RewriteCond %{QUERY_STRING} (.*)
RerwiteRule ^(.*) http://www.domain.com/$1 [R,CO=querystring:%1:.mydomain.com]
where the %1 is a backreference to the match in the RewriteCond.
I haven't tested this, but it should point you in the right direction.
Joshua.
---------------------------------------------------------------------
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] Rewrite-problem
Posted by Jurgen <ap...@squarehosting.com>.
Hi,
I don't know if this resolved or not, but maybe you try something like this:
# you might want to use a + if you want to test for the existence of a query string
RewriteCond %{QUERY_STRING} ^(.+)$
# The ? after the end of the redirection removes the query string.
RewriteRule ^(.*) http://www.otherdomain.nl/$1? [R,CO=campaign:%1:.domain.nl]
Jurgen
On Mon, 10 Feb 2003 01:40:30 +0100
"Sander Holthaus - Orange XL" <in...@orangexl.com> wrote:
> Sorry, my appologies, the cookie IS written, I forgot to use % instead of $.
> But the ? is still in the path.
>
> ----- Original Message -----
> From: "Sander Holthaus - Orange XL" <in...@orangexl.com>
> To: <us...@httpd.apache.org>
> Sent: Monday, February 10, 2003 1:24 AM
> Subject: Re: [users@httpd] Rewrite-problem
>
>
> > Thanks Josh, but that's not the case. The ? is in the path and I just
> cannot
> > seem to get it to match.
> > I tried you suggestion (and a few variations of it) but it puts the server
> > in an infinite loop, because as I said, the ?-mark is in the path found by
> > Apache, and thus the rewritten URL also has a querystring in it.
> >
> > I used:
> >
> > RewriteEngine on
> > # RewriteCond %{QUERY_STRING} !^$ # always true?!
> > RewriteCond %{QUERY_STRING} (.*)
> > RewriteRule ^(.*) http://www.otherdomain.nl/$1
> > [R,CO=campaign:$2:.domain.nl]
> >
> > I don't really know what is, but after some extensive testing, I can only
> > conclude that the rewrite-engine in Apache 2 is still bugged. I could have
> > used $4 or whatever in the above example, it still would have done the
> same,
> > the full path AND query_string are appended to the redirect-URL and the
> > cookie is NOT written.
> >
> > Should I file a bugreport or am I really missing something here?
> >
> > Kind Regards,
> > Sander Holthaus
> >
> > ----- Original Message -----
> > From: "Joshua Slive" <jo...@slive.ca>
> > To: <us...@httpd.apache.org>
> > Sent: Monday, February 10, 2003 12:22 AM
> > Subject: Re: [users@httpd] Rewrite-problem
> >
> >
> > >
> > > On Mon, 10 Feb 2003, Sander Holthaus - Orange XL wrote:
> > > > RewriteRule ^([^?]*)\?(.*)$ <http://www.mydomain.com$1>
> > > > http://www.mydomain.com$1
> > > > [R,CO=querystring:$2:.mydomain.com]
> > > > # put eveything without/until a ? in $1, put everything after
> a/the
> > > > first ? in $2
> > > > # $1 will be the redirect-uri
> > > > # $2 will be written as a cookie
> > > >
> > > > The problem seems to the \? in the regex of the rewriterule. The regex
> > > > will
> > > > not match addresses with a ? in them.
> > >
> > > RewriteRule matches only the URL-Path not including the query string.
> To
> > > match the query string, you need to use a RewriteCond as in
> > >
> > > RewriteCond %{QUERY_STRING} (.*)
> > > RerwiteRule ^(.*) http://www.domain.com/$1
> > [R,CO=querystring:%1:.mydomain.com]
> > >
> > > where the %1 is a backreference to the match in the RewriteCond.
> > >
> > > I haven't tested this, but it should point you in the right direction.
> > >
> > > Joshua.
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
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] Rewrite-problem
Posted by Sander Holthaus - Orange XL <in...@orangexl.com>.
Sorry, my appologies, the cookie IS written, I forgot to use % instead of $.
But the ? is still in the path.
----- Original Message -----
From: "Sander Holthaus - Orange XL" <in...@orangexl.com>
To: <us...@httpd.apache.org>
Sent: Monday, February 10, 2003 1:24 AM
Subject: Re: [users@httpd] Rewrite-problem
> Thanks Josh, but that's not the case. The ? is in the path and I just
cannot
> seem to get it to match.
> I tried you suggestion (and a few variations of it) but it puts the server
> in an infinite loop, because as I said, the ?-mark is in the path found by
> Apache, and thus the rewritten URL also has a querystring in it.
>
> I used:
>
> RewriteEngine on
> # RewriteCond %{QUERY_STRING} !^$ # always true?!
> RewriteCond %{QUERY_STRING} (.*)
> RewriteRule ^(.*) http://www.otherdomain.nl/$1
> [R,CO=campaign:$2:.domain.nl]
>
> I don't really know what is, but after some extensive testing, I can only
> conclude that the rewrite-engine in Apache 2 is still bugged. I could have
> used $4 or whatever in the above example, it still would have done the
same,
> the full path AND query_string are appended to the redirect-URL and the
> cookie is NOT written.
>
> Should I file a bugreport or am I really missing something here?
>
> Kind Regards,
> Sander Holthaus
>
> ----- Original Message -----
> From: "Joshua Slive" <jo...@slive.ca>
> To: <us...@httpd.apache.org>
> Sent: Monday, February 10, 2003 12:22 AM
> Subject: Re: [users@httpd] Rewrite-problem
>
>
> >
> > On Mon, 10 Feb 2003, Sander Holthaus - Orange XL wrote:
> > > RewriteRule ^([^?]*)\?(.*)$ <http://www.mydomain.com$1>
> > > http://www.mydomain.com$1
> > > [R,CO=querystring:$2:.mydomain.com]
> > > # put eveything without/until a ? in $1, put everything after
a/the
> > > first ? in $2
> > > # $1 will be the redirect-uri
> > > # $2 will be written as a cookie
> > >
> > > The problem seems to the \? in the regex of the rewriterule. The regex
> > > will
> > > not match addresses with a ? in them.
> >
> > RewriteRule matches only the URL-Path not including the query string.
To
> > match the query string, you need to use a RewriteCond as in
> >
> > RewriteCond %{QUERY_STRING} (.*)
> > RerwiteRule ^(.*) http://www.domain.com/$1
> [R,CO=querystring:%1:.mydomain.com]
> >
> > where the %1 is a backreference to the match in the RewriteCond.
> >
> > I haven't tested this, but it should point you in the right direction.
> >
> > Joshua.
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>
>
> ---------------------------------------------------------------------
> 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
>
>
---------------------------------------------------------------------
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] Rewrite-problem
Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 10 Feb 2003, Sander Holthaus - Orange XL wrote:
> I tried you suggestion (and a few variations of it) but it puts the server
> in an infinite loop, because as I said, the ?-mark is in the path found by
> Apache, and thus the rewritten URL also has a querystring in it.
Ahhh... If you want to cut off the query string, you need to tag a ? on to
the end of the RewriteRule. By default, mod_rewrite passes the query
string from the original request to the new request untouched. It is NOT
matched in the (.*). This is all in the docs (although, admittedly, so
are a million other things; the mod_rewrite docs are quite dense).
> RewriteEngine on
> # RewriteCond %{QUERY_STRING} !^$ # always true?!
> RewriteCond %{QUERY_STRING} (.*)
> RewriteRule ^(.*) http://www.otherdomain.nl/$1
> [R,CO=campaign:$2:.domain.nl]
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^(.*) http://www.otherdomain.nl/$1? [R,CO=campaign:%1:.domain.nl]
You need to use %1 to get the back-reference. $2 will be empty.
And don't even think about filing a bug report on this until you have
tried the RewriteLog at RewriteLogLevel 9 to see exactly what mod_rewrite
is doing.
Joshua.
---------------------------------------------------------------------
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] Rewrite-problem
Posted by Sander Holthaus - Orange XL <in...@orangexl.com>.
Thanks Josh, but that's not the case. The ? is in the path and I just cannot
seem to get it to match.
I tried you suggestion (and a few variations of it) but it puts the server
in an infinite loop, because as I said, the ?-mark is in the path found by
Apache, and thus the rewritten URL also has a querystring in it.
I used:
RewriteEngine on
# RewriteCond %{QUERY_STRING} !^$ # always true?!
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^(.*) http://www.otherdomain.nl/$1
[R,CO=campaign:$2:.domain.nl]
I don't really know what is, but after some extensive testing, I can only
conclude that the rewrite-engine in Apache 2 is still bugged. I could have
used $4 or whatever in the above example, it still would have done the same,
the full path AND query_string are appended to the redirect-URL and the
cookie is NOT written.
Should I file a bugreport or am I really missing something here?
Kind Regards,
Sander Holthaus
----- Original Message -----
From: "Joshua Slive" <jo...@slive.ca>
To: <us...@httpd.apache.org>
Sent: Monday, February 10, 2003 12:22 AM
Subject: Re: [users@httpd] Rewrite-problem
>
> On Mon, 10 Feb 2003, Sander Holthaus - Orange XL wrote:
> > RewriteRule ^([^?]*)\?(.*)$ <http://www.mydomain.com$1>
> > http://www.mydomain.com$1
> > [R,CO=querystring:$2:.mydomain.com]
> > # put eveything without/until a ? in $1, put everything after a/the
> > first ? in $2
> > # $1 will be the redirect-uri
> > # $2 will be written as a cookie
> >
> > The problem seems to the \? in the regex of the rewriterule. The regex
> > will
> > not match addresses with a ? in them.
>
> RewriteRule matches only the URL-Path not including the query string. To
> match the query string, you need to use a RewriteCond as in
>
> RewriteCond %{QUERY_STRING} (.*)
> RerwiteRule ^(.*) http://www.domain.com/$1
[R,CO=querystring:%1:.mydomain.com]
>
> where the %1 is a backreference to the match in the RewriteCond.
>
> I haven't tested this, but it should point you in the right direction.
>
> Joshua.
>
> ---------------------------------------------------------------------
> 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
>
>
---------------------------------------------------------------------
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