views:

39

answers:

2

I want to create an application in PHP implementing virtual directory feature.
Example: http://mydomain.com/user001 will display the contents of the url http://mydomain.com/index.php?user=user001. How can I do that?

Note:
I am using Apache server.

+5  A: 

The traditional way to do it is mod_rewrite.

Mike
If I want to do that for a blogging application then I have to do mod_rewrite for every entry. Example: Every time I create a question in stackoverflow.com, it automatically creates a virtual directory for that question.
chanchal1987
no, you'd set up a regex in your rewrite rule to match any entry.
GrandmasterB
@GrandmasterB: OK Thanks...
chanchal1987
+1  A: 

Please read this freidnly article regarding rewrite:
http://www.noupe.com/php/10-mod_rewrite-rules-you-should-know.html

Next, try to find a simple way in PHP to pharse this variable $_SERVER['REQUEST_URI'].

After toing that, you have the name of the directory and you can get its data from the DB

fatnjazzy