The homepage on my website has a number of users, listed. Each user has 'view profile' link that takes you to www.mysite.com/user-profiles/profile.php?id=32, the id being relevant to the user.
Is it possible to use URL Rewriting to find the name and surnamce of the user for that ID in the database and rewrite it too something like?
www.mysite.com/user-profiles/john-a-doe
Any help would be greatly appreciated...
解决方案
I recommend doing it this way
Print URLs in the following format mysite.com/user-profiles/(ID)/(NAME) then use this to rewrite:
RewriteRule ^user-profiles/([^/]*)/([^/]*)$ /user-profiles/profile.php?id=$1&name=$2 [L]
then in your profile.php SELECT for id and name
Note: There are several ways to achieve what you want, but since you're using Full Name for (NAME) that's gonna cause a problem (noted by Ronn0) when two users (or more) have the same name, with what I've suggested you're able to eliminate that problem.