views:

22

answers:

2

Hello,

I have a MySQL table designated for storing usernames, passwords, etc. In this table, one field is called "username." I would like to create a user page for each user that gets entered into the database. I would like the URL for any given user page to be http://foo.com/member/username. How could I do this?

Thanks in advance,

John

A: 

Using mod_rewrite you could create a single script (foo.com/member/index.php) and re-write the url so that the server treats /member/username as /member/index.php?uid=username.

Your main script would be responsible for loading and outputting the user information.

Your rewrite would look something like:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+) index.php?uid=$1
jasonbar
OK... I put that in the .htaccess file, right?
John
@John: Yeah, since you'll be using .htaccess, you can use the simplified version in the answer.
jasonbar
A: 

Hm... PHP and mod_rewrite

You could rewrite the url member/xyz to member.php?username=xyz and then let the php-script display some data.

henchman