Page 1 of 1

user registration and directory question

Posted: Thu Sep 22, 2005 2:43 am
by ecaandrew
i have it so when a user signs up, it will create a directory


blah.com/username



but my question is how do i make it so there is a index.php file in that directory, and it will retrieve all the information through a database?


cause usually i do view.php?id=999, and i would grab the information of the user from the database using GET ID 999



but how do i make it so each user has blah.com/username


thanks!

Posted: Thu Sep 22, 2005 4:19 am
by s.dot
hmm i recently did this using mod_rewrite

it will take your blah.com/view.php?ID=username and make a blah.com/username URL out of it.. giving the illusion that each person has their own directory.

You need to edit (or create) your .htaccess file and add the following lines:

Code: Select all

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)(/)?$ view.php?ID=$1
Edit: I'm not too familar with mod rewrite, but I think it's for Apache servers only.

Posted: Thu Sep 22, 2005 4:33 am
by ecaandrew
so how exactly would i go about doing this, where do i create the .htaccess file? thanks

Posted: Thu Sep 22, 2005 4:35 am
by s.dot
In your root directory

usually something like:

/home/usr/public_html/

Posted: Thu Sep 22, 2005 4:37 am
by ecaandrew
awesome i got it to work, thank yo so much!