pass variables to htaccess from php script
Posted: Mon Oct 12, 2009 1:15 am
I just got my htaccess redirect working, but I'd like to make it better
when you log in the url is typically something like this
http://www.mydomain.com/profile.php?id=1234567890
the htaccess file has a redirect like this
now you can reach the same location by typing in
http://www.mydomain.com/1234567890
the problem is I've developed my whole site and database around the user id being a number
so, I'd like to be able to add a row in my user table for usernames
and point the url to this sort of thing
http://www.mydomain.com/username
Is there a way to make the htaccess file redirect this
http://www.mydomain.com/username
to this
http://www.mydomain.com/profile.php?id=1234567890
by making a mysql call that grabs the corresponding user id for the username and redirecting?
Any help would be appreciated. Thanks.
when you log in the url is typically something like this
http://www.mydomain.com/profile.php?id=1234567890
the htaccess file has a redirect like this
Code: Select all
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ profile.php?id=$1 [NC,L]
http://www.mydomain.com/1234567890
the problem is I've developed my whole site and database around the user id being a number
so, I'd like to be able to add a row in my user table for usernames
and point the url to this sort of thing
http://www.mydomain.com/username
Is there a way to make the htaccess file redirect this
http://www.mydomain.com/username
to this
http://www.mydomain.com/profile.php?id=1234567890
by making a mysql call that grabs the corresponding user id for the username and redirecting?
Any help would be appreciated. Thanks.