开发者

Dynamic User Directorys

开发者 https://www.devze.com 2023-01-22 14:20 出处:网络
When a user registers I am wondering how to create them a dynamic directory (which will show they\'re profile), such as Facebook / MySpace.

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 i开发者_JAVA百科s 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


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.


If your code is running under Apache, you should look into mod_rewrite and make the "folders" virtual.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

0

精彩评论

暂无评论...
验证码 换一张
取 消