You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Søren Neigaard <s....@mobilethink.dk> on 2004/06/30 15:25:01 UTC

[users@httpd] mod_rewrite matching on querystring?

Ive tried to get mod_rewrite to match this url (the complete url, and only the complete url):

  /my/own/server?U1=44

Ive tried with this rule:

  RewriteRule ^/my/own/server.+U1=44[^\0-9] http://xxx/inde.htm? [P,L]

But it seems not to work, and in the rewrite log (loglevel set to 3) i get this:

   init rewrite engine with requested uri /my/own/server
   applying pattern '^/my/own/server.+U1=44[^\0-9]' to uri '/my/own/server'

And then it gets passed through. It seems like I cant match on the query string, is that correct? And if I can, how would I do this?

Med venlig hilsen/Best regards
Søren Neigaard
System Architect
................................
Mobilethink A/S
Arosgaarden
Åboulevarden 23, 4.sal
DK - 8000 Århus C
Telefon: +45 86207800
Direct: +45 86207810
Fax: +45 86207801
Email: s.neigaard@mobilethink.dk
Web: www.mobilethink.dk
................................

---------------------------------------------------------------------
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] mod_rewrite matching on querystring?

Posted by Joshua Slive <js...@gmail.com>.
On Wed, 30 Jun 2004 16:08:57 +0200, Søren Neigaard
<s....@mobilethink.dk> wrote:

> Ok - One more problem though... I have two rules now:
> 
> RewriteCond %{QUERY_STRING} U1=44[^\0-9]
> RewriteRule ^/my(.*) http://yyy/index.htm? [P,L]
> RewriteRule ^/my(.*) http://xxx/index.htm? [R,L]
> 
> What I want is to get all request to /my/own/server?U1=44 proxied to yyy,
> and all /my* redirected to xxx, but it seems it first matches the first
> rule, then looks at the next rule and it matches that also so thats the rule
> it uses. Is that assuption true, or? And how would i fix this? As I
> understand it the RewriteCond only applys to the first rule right?

Yes, the RewriteCond applies only to the first rule.

But the "L" flag on the RewriteRule indicates that no further rules
should be evaluated.

If you are still having problems, make sure to use the RewriteLog to debug.

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] mod_rewrite matching on querystring?

Posted by Søren Neigaard <s....@mobilethink.dk>.
-----Original Message-----
From: Joshua Slive [mailto:jslive@gmail.com] 
Sent: 30. juni 2004 15:42
To: users@httpd.apache.org
Subject: Re: [users@httpd] mod_rewrite matching on querystring?

On Wed, 30 Jun 2004 15:25:01 +0200, Søren Neigaard
<s....@mobilethink.dk> wrote:
> Ive tried to get mod_rewrite to match this url (the complete url, and only
the complete url):
> 
>   /my/own/server?U1=44
> 
> Ive tried with this rule:
> 
>   RewriteRule ^/my/own/server.+U1=44[^\0-9] http://xxx/inde.htm? [P,L]

> RewriteRule won't match on the query string, but you can use RewriteCond:
>
> RewriteCond %{QUERY_STRING} U1=44[^\0-9]
> RewriteRule ^/my/own/server http://xxx/inde.htm? [P,L]

Ok - One more problem though... I have two rules now:

RewriteCond %{QUERY_STRING} U1=44[^\0-9]
RewriteRule ^/my(.*) http://yyy/index.htm? [P,L]
RewriteRule ^/my(.*) http://xxx/index.htm? [R,L]

What I want is to get all request to /my/own/server?U1=44 proxied to yyy,
and all /my* redirected to xxx, but it seems it first matches the first
rule, then looks at the next rule and it matches that also so thats the rule
it uses. Is that assuption true, or? And how would i fix this? As I
understand it the RewriteCond only applys to the first rule right?

Best regards
Søren



---------------------------------------------------------------------
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] mod_rewrite matching on querystring?

Posted by Joshua Slive <js...@gmail.com>.
On Wed, 30 Jun 2004 15:25:01 +0200, Søren Neigaard
<s....@mobilethink.dk> wrote:
> Ive tried to get mod_rewrite to match this url (the complete url, and only the complete url):
> 
>   /my/own/server?U1=44
> 
> Ive tried with this rule:
> 
>   RewriteRule ^/my/own/server.+U1=44[^\0-9] http://xxx/inde.htm? [P,L]

RewriteRule won't match on the query string, but you can use RewriteCond:

RewriteCond %{QUERY_STRING} U1=44[^\0-9]
RewriteRule ^/my/own/server http://xxx/inde.htm? [P,L]

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