Reputation: 65
I've finally got the mod_rewrite rule down somewhat, but would like to do a bit more with it and am not sure how. Here's what I currently have:
RewriteRule ^rider/(.*)/(.*)*$ /bar/standings/rider.php?lnum=$1&short=$2
Which allows me to do this:
http://pca.localhost/rider/214142/sme
instead of
http://pca.localhost/bar/standings/rider.php?lnum=214142&short=sme
That works all fine and dandy, but I'd like to refine it more, so that it would be:
http://pca.localhost/rider/fred/flinstone
However, I need to pass the lnum variable because it's the only true id key (ie their could be two people in the db named fred flinstone). The short variable doesn't matter as much. My goal is to somehow pass just the name without showing the lnum variable. Is there a way to do this? Can I somehow hide the lnum variable when it's passed? Or, do I need to do some slick php/mysql work?
Any advice, comments or suggestions are welcomed.
Upvotes: 0
Views: 86
Reputation: 3711
If you have to get the ID from the DB in the first place, why not using a session ID in a cookie? Or the session ID as GET or POST parameter (i.e. with a hidden form field).
Anyway, it is not very safe to expose the user ID like that. Use a "random" ID, like a session ID, and link it to the user ID.
Upvotes: 0
Reputation: 2469
You can try generating a unique id for the user at the time of registration and use that throughout. For example for fred flinstone
unique id = fred (if there's no fred already present) unique id = fred-flinstone (if there's already a fred present) unique id = fred-flinstone1 (if there's already a fred flinstone present)
Some logic of this sort.
Upvotes: 0
Reputation: 799560
The only key you get from the client when they go to your website fresh is the URL. If the URL does not uniquely identify the page to view then you must either show some sort of disambiguation page or you must abandon the idea.
Upvotes: 2