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

Jonathan Vanasco wrote:

Currently a page is accessed like this:
    /user/profile?id=X

I'm trying to get url schemes like this to map to that page
    /users/X
    /users/X/profile

I tried doing it in mod_rewrite.  there i ran into 2 problems:
    a_ the new mapping is shown to the user
b_ i can either replace the query string entirely, or append the new 'id' to it. if there's an existing id param in the string though, i run into a collison


Reply via email to