I am trying to implement a SEO friendly URL.
I have a user detail page which has the url schema as such "$_SERVER["HTTP_HOST"]/[user-name]/[user-id]
. I use the [user-id] to query user information in my database. However, if the [user-name] in the url does not match the user name that I query based on the database, I would like to auto correct the url in the browser.
For example there are two people, "mickey" and "minnie". mickey's user id is 1 and minnie is 2. So if a user key in "$_SERVER["HTTP_HOST"]/mickey/2
", the system will check the database to make sure "mickey" in the url matches with the name of user id 2. If found out that it does not match, the system will redirect user to url "$_SERVER["HTTP_HOST"]/minnie/2
".
How could I do that?
Thanks in advance=)