I have tried this with both mod_jk and mod_proxy and get the same result.
Using this mod_rewrite rule works fine:
RewriteRule ^/(.*)\-blah.html$ /blah/blah/blah?blah=l2vb&party_name=$1 [R,L]
The trouble with this is the ugly new URL /blah/blah/blah?blah=l2vb&party_name
is displayed in the address line of the browser, which is what I'd hoped to avoid. It seems to be the [R]
flag that does this.
The following rule hides the ugly URL and displays only the new pretty one:
RewriteRule ^/(.*)\-blah.html$ /blah/blah/blah?blah=l2vb&party_name=$1 [P,L]
NB: The only difference here is the flags at the end between the []
.
The trouble is that if the user already had something in their shopping cart it gets emptied. Somehow their connect session (or whatever it is - rather out of my depth here!) gets re-initialised so they appear to be starting from scratch.
I have tried several other combinations of flags, like [PT,L]
, [R,PT]
etc and had no luck so far.
The [R]
flag means 302 Redirect Code, which obviously changes the URL in a browser.
I think you need QSA
flag:
RewriteRule ^/(.*)\-blah.html$ /blah/blah/blah?blah=l2vb&party_name=$1 [QSA,L]
QSA
flag will preserve existing query string (to be more precise, will append it to the new URL) .. which otherwise gets lost as you DO manipulate with query string. I think session ID or something may be passed via query string .. and when URL gets rewritten it is lost, so server creates new session. If that is the case, then the above should solve your problem.
Apache documentation: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa
精彩评论