Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite query-string question

can't get the"?string=xyz" appended after a rewrite

         

isorg

1:50 pm on Mar 27, 2004 (gmt 0)

10+ Year Member



I am re-writing

servername.com/profile/john/phone to servername.com/profile.html?member=john&section=phone

using


RewriteRule ^profile/(.*)/(.*)$ profile.html?member=$1&section=$2 [L]

Now, the problem comes when the user logs in and tries to get

servername.com/profile/john/phone?Username=aaa&SessionID=bbb&Option=ccc

to servername.com/profile.html?member=john&section=phone&Username=aaa&SessionID=bbb&Option=ccc

using

RewriteRule ^profile/(.*)/(.*)\?(.*)$ profile.html?member=$1&section=$2\&$3

The "?Username=aaa&SessionID=bbb&Option=ccc" are not passed to the profile.html PHP script at all. I have echo'd $QUERY_STRING from the profile.html scipt and only "member=john&section=phone" comes through.

There could be any number of variables after the? and in any order, so I was hoping that the third (.*) and "\&$3" would simply append the whole string to the re-written URL no matter what's in it.

What am I doing wrong here?

jdMorgan

3:31 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use the [QSA] flag (Query String Append) to prevent your newly-added query parameters from overwriting the sessionID, etc.

RewriteRule ^profile/([^/]*)/(.*)$ profile.html?member=$1&section=$2 [[b]QSA[/b],L]

Jim

isorg

4:04 pm on Mar 27, 2004 (gmt 0)

10+ Year Member



Thanks a million.