tags:

views:

16

answers:

1

Hi,

I'm using php on apache with mysql.

I want to let users enter a url into their browser to see a custom user page for themselves, just like twitter does. For example, they could enter urls like:

www.mysite.com/johndoe
www.mysite.com/janedoe

and see that user's page. How could I do this with php and apache? I don't want to create a folder on disk for every user like above, I'd instead kind of like to catch the url and generate the page on the fly for them,

Thanks

A: 

What you are looking for is URL rewriting and it can be done using Apache mod_rewrite.

For example, if your urls are

www.mysite.com/user/johndoe
www.mysite.com/user/janedoe

and you setup a mod_rewrite rule

RewriteRule /user/([a-zA-Z]+) /get_users.php?username=$1

then in get_users.php you can retrieve the value for username from

$_GET["username"]
Charlotte Moller