Forum Moderators: phranque

Message Too Old, No Replies

QUERY STRING in RewriteCond

Adding a URL parameter to an original query string

         

mendoza

6:21 pm on May 13, 2008 (gmt 0)

10+ Year Member




Hello,

Need some help, I haven't found addressed in the Forum.

I have a URL:

[myserverIP:8080...]

and need to redirect to:

[myserverIP:8090...]

the "category" value is obtained from the original URL, that is from .../int-newsml?... and it could change to other values. E.g. world-newsml, sport-newsml, etc...

So I did this by steps, experimenting and got to fetch the query parameter in the orignal URL and add it to the new URL, (this is in an httpd.conf file):

RewriteCond %{QUERY_STRING} ^itemid=(.*)
RewriteRule ^/client/dwnl/(.*)$ [myserverIP:8090...] [R=301,L]

THE ABOVE WORKS FINE, APPENDS THE ORIGINAL QUERY STRING. BUT WHEN I TRY TO ADD THE OTHER PARAMETER, THE CATEGORY VALUE, IT DOESN'T ADD THE itemid PARAMETER ANYMORE.

RewriteCond %{QUERY_STRING} ^itemid=(.*)
RewriteRule ^/client/dwnl/(.*)-newsml$ [myserverIP:8090...] [R=301,L]

I'VE TRIED ADDING A "&" BUT IT DOESN'T WORK
THANKS FOR YOUR HELP

jdMorgan

6:31 pm on May 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the [QSA] flag (Query String Append) for RewriteRule [httpd.apache.org].

Jim

mendoza

6:49 pm on May 13, 2008 (gmt 0)

10+ Year Member



Thanks Jim, adding the QSA flag did the job!