You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Andoni <an...@eurokom.ie> on 2004/12/17 13:09:41 UTC

[users@httpd] Rewriting /path -> query string.

Hello,

I feel as though this one package has taken years off my life. I have once again been asked to get a simple rewrite going and once again I wrestle.

What I am trying to do is simple:
People click on one of two links:

www.xxx.com/mail?file=123.txt&com=1

or 

www.xxx.com/mymail2?file=123.txt&com=1

and I need these translated to:

www.xxx.com/strutsprog.do?type=mail&file=123.txt&com=1

or

www.xxx.com/strutsprog.do?type=mymail2&file=123.txt&com=1

The problem seems to be that mod_rewrite is only reading the path part as the rewrite log says:

...ial] (3) applying pattern '^/mail\?file=(.*)$' to uri '/mail'

but why is it not applying the pattern to uri '/mail?file=123.txt&com=1' instead of just to '/mail' and how can I get it to do this.

The rule I'm using is:

RewriteRule ^/mail\?(.*)$ http://www.xxx.com/strutsprog.do?type=mail&$1 [R,L]

Thanks in advance for any help,

Andoni.

Re: [users@httpd] Rewriting /path -> query string.

Posted by Joshua Slive <js...@gmail.com>.
On Fri, 17 Dec 2004 12:09:41 +0000, Andoni <an...@eurokom.ie> wrote:
>  
> Hello, 
>   
> I feel as though this one package has taken years off my life. I have once
> again been asked to get a simple rewrite going and once again I wrestle. 
>   
> What I am trying to do is simple: 
> People click on one of two links: 
>   
> www.xxx.com/mail?file=123.txt&com=1 
>   
> or 
>   
> www.xxx.com/mymail2?file=123.txt&com=1 
>   
> and I need these translated to: 
>   
> www.xxx.com/strutsprog.do?type=mail&file=123.txt&com=1 
>   
> or 
>   
> www.xxx.com/strutsprog.do?type=mymail2&file=123.txt&com=1 
>   
> The problem seems to be that mod_rewrite is only reading the path part as
> the rewrite log says: 
>   
> ...ial] (3) applying pattern '^/mail\?file=(.*)$' to uri '/mail' 
>   
> but why is it not applying the pattern to uri '/mail?file=123.txt&com=1'
> instead of just to '/mail' and how can I get it to do this. 
>   
> The rule I'm using is: 
>   
> RewriteRule ^/mail\?(.*)$ http://www.xxx.com/strutsprog.do?type=mail&$1
> [R,L]

Check the big box that says "Query String" in the docs:
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html#rewriterule

It will tell you that you need something more like

 RewriteRule ^/mail$ http://www.xxx.com/strutsprog.do?type=mail  [QSA,R,L]

---------------------------------------------------------------------
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