user registration and directory question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

user registration and directory question

Post 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!
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

so how exactly would i go about doing this, where do i create the .htaccess file? thanks
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

In your root directory

usually something like:

/home/usr/public_html/
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

awesome i got it to work, thank yo so much!
Post Reply