
modperl-list at 2xlp
Dec 24, 2005, 10:33 AM
Post #2 of 2
(447 views)
Permalink
|
|
Re: [OT] Re: modifying the query string & uri without a redirect ?
[In reply to]
|
|
(OT) Ah. Very odd. I misinterpreted the NS flag I had: RewriteRule ^/users/([\d]{1,9})$ /users/?id=$1 [QSA,L] Now I have RewriteRule ^/users/([\d]{1,9})(/)?$ /users/?id=$1 [QSA,NS,L] And it all works fine. I realized that I wasn't seeing an actual redirect, but the query string was appeneded into the browser location. With the NS, flag, the query string will not show. I'm not sure why that happens or how. Maybe its in part because I'm running this on localhost. festive festivus, Jonathan On Dec 24, 2005, at 9:10 AM, John ORourke wrote: > I'll give you the mod_rewrite solution but a mod_perl handler > version is similarly simple. > > RewriteRule /user/(.+)(/profile)? /user/profile?id=$1 [NS] > > This creates an internal subrequest (ie. users don't see it) for > the new URI, and if I remember rightly mod_rewrite will sort out > your query string for you. If you have collisions with the 'id' > parameter I'd suggest changing your program logic - HTTP doesn't > strongly define parameter ordering or precedence so you might get > unexpected results! > > mod_rewrite only does an external redirect (so users see it) if the > destination URI is absolute (http://...) or if you add the 'R' flag > (like this: "..... ?id=$1 [R,NS]" ) > > $preferred_term_of_merriment $choice_of_religious_holiday, > John
|