动态用户目录
当用户注册时,我想知道如何为他们创建一个动态目录(这将显示他们的个人资料),例如 Facebook / MySpace。
我希望该目录是他们的用户名的目录。用户名存储在数据库中。
正在使用的技术
数据库:MySQL
前端:PHP
我已经考虑过使用 PHP MKDIR 命令来创建单独的目录,但我真的不希望 FTP 被文件夹淹没
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Facebook 不为用户提供自己的目录。为用户提供自己的目录需要大量的服务器资源、后端的大量工作,并且在拥有数百万用户后,文件分配表中的混乱会导致页面加载非常可怕。然后考虑到所有浪费的磁盘空间,因为硬盘驱动器在分页系统上运行,并且每个目录都需要一个index.html 文件...
Facebook 所做的是将一行写入.htaccess 文件。当用户说他们想要
www.facebook.com/username
时,Facebook 会添加以下内容:甚至还有更好的方法可以做到这一点。您可以将所有内容重定向到
parse_request.php
,这将确定您是否正在请求用户的特定页面,或者您是否正在请求静态页面(例如welcome.php
)这不应该改变。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: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 (likewelcome.php
) which shouldn't change.如果您的代码在 Apache 下运行,您应该查看 mod_rewrite 并使“文件夹”虚拟。
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
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