我想为不同的用户创建域

发布于 2024-09-12 22:37:36 字数 331 浏览 1 评论 0原文

我有 www.football.comwww.baseball.com 等域名。

它们与父级 www.game.com 及其管理页面 www.game.com/admin 链接。

我想为不同的用户创建诸如 www.football.com/userid1/adminwww.baseball.com/userid2/admin 等内容。

所有域都映射到同一 IP,并且只有一个管理文件夹。如果我使用CakePHP,是否可以实现上述目标?

I have domains like www.football.com and www.baseball.com.

They are linked with www.game.com, which is the parent, and its admin page, www.game.com/admin.

i want to create something like www.football.com/userid1/admin, www.baseball.com/userid2/admin, etc. for different users.

All the domains are mapped to same IP and there is only one admin folder. If I use CakePHP, is it possible to achieve the above?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

北斗星光 2024-09-19 22:37:36

做起来很简单,但在细节上却很挑剔。您将 Apache 配置为将所有这些域指向同一组 PHP 文件,然后只需检查 $_SERVER['HTTP_HOST'] 即可查看实际请求的域:

switch ($_SERVER['HTTP_HOST']) {
   case 'www.baseball.com':
   case 'baseball.com':
        // do baseball.com stuff here
        break;
   case 'www.football.com':
   case 'football.com':
        // football stuff here
    default:
       // just in case no valid hostname was given (e.g. coming in via IP only)
       // do default stuff here
}

在您的其余部分中适当小心代码和模板,您可以轻松确定要输出哪个站点的图像/样式表/内容,但基本上对所有这些都使用相同的核心逻辑。

It's simple to do, but gets nitpicky in the details. You configure Apache to point all those domains to the same set of PHP files, then you simply check $_SERVER['HTTP_HOST'] to see which domain was actually requested:

switch ($_SERVER['HTTP_HOST']) {
   case 'www.baseball.com':
   case 'baseball.com':
        // do baseball.com stuff here
        break;
   case 'www.football.com':
   case 'football.com':
        // football stuff here
    default:
       // just in case no valid hostname was given (e.g. coming in via IP only)
       // do default stuff here
}

With appropriate care in the rest of your code and templates, you can easily determine which site's images/stylesheets/content to output, but basically use the same core logic for all of them.

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