Forum Moderators: phranque
For instance, I have several thousand users and I want to give them their own URLs instead of using user-1.htm as their page.
I know I'll need a table to store this information.
My problem is that I don't know how to get php to do the rewriting, and how php might need to interact with the .htaccess file so that php gets the chance to rewrite.
Ex. if someone visits my links.htm page, I want them to stay there. If they visit my /users/ilovecheese/ page them I want to redirect them to /users/user-10.htm.
Aaron
Example
/users/ilovecheese/ to /users/user-10.htm (rigth)
in .htaccess you can say,
RewriteCond %{REQUEST_URI}!/users/(.*)\.htm
RewriteCond %{REQUEST_URI} /users/(.*)
RewriteRule /users/(.*) /detectuserID.php?username=$1[QSA,L]
and inside detectuserID.php you are getting $_GET['username'] and then search the username inside DB, get the userid and redirect them to /users/user-ID.htm
again you can write
RewriteCond %{REQUEST_URI} /users/user-(.*)\.html
RewriteRule /users/user-(.*)\.html /displayuserdetails.php?userid=$1[QSA,L]
I am in a hurry so I might have messed few things but I think this will atleast give you a direction.
Thanks,
AjiNIMC