phpmysqlfacebookvirtual-directorymyspace

Dynamic User Directorys


When a user registers I am wondering how to create them a dynamic directory (which will show they're profile), such as Facebook / MySpace.

I want the directory to be that of their username. The username is stored on the database.

Technologies being used

Database: MySQL

Front End: PHP

I've looked at using the PHP MKDIR command to create an individual directory, but i don't really want the FTP to be overrun with folders


Solution

  • Facebook doesn't give users their own directory. Giving a user their own directory takes lots of server resources, lots of effort on the back-end, and after you have several million users the clutter in the file-allocation table would cause page loads to be horrendous. Then take into account all the wasted disk space since hard drives operate on a paging system, AND you'd need an index.html file for each directory...

    What Facebook does instead is write a line to a .htaccess file. When a user says they want www.facebook.com/username, facebook adds the following:

    RewriteRule username profile.php?id=<user id>
    

    There are better ways to do this, even. You could have EVERYTHING redirect to parse_request.php, which will determine if you were requesting a user's specific page, or if you were requesting a static page (like welcome.php) which shouldn't change.