动态用户目录

发布于 2024-09-29 19:26:12 字数 238 浏览 9 评论 0原文

当用户注册时,我想知道如何为他们创建一个动态目录(这将显示他们的个人资料),例如 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏大泽ㄣ 2024-10-06 19:26:12

Facebook 不为用户提供自己的目录。为用户提供自己的目录需要大量的服务器资源、后端的大量工作,并且在拥有数百万用户后,文件分配表中的混乱会导致页面加载非常可怕。然后考虑到所有浪费的磁盘空间,因为硬盘驱动器在分页系统上运行,并且每个目录都需要一个index.html 文件...

Facebook 所做的是将一行写入.htaccess 文件。当用户说他们想要 www.facebook.com/username 时,Facebook 会添加以下内容:

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

甚至还有更好的方法可以做到这一点。您可以将所有内容重定向到 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:

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.

阳光的暖冬 2024-10-06 19:26:12

如果您的代码在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文