如何根据用于访问网站的 URL 加载不同的内容 i CodeIgniter

发布于 2024-12-15 09:18:13 字数 295 浏览 2 评论 0原文

我确信我不是第一个想到这个问题的人,但我没有运气在谷歌中形成正确的搜索查询来查找信息。这就是我想要做的:

我有一个基于 CodeIgniter 的网站。我将把基本内容存储到数据库的表中。我想我会将域名存储在表中,并使用表行的唯一 id 作为从数据库中查询其余视图的适当内容的方法。例如。 MyDomain.com 在该行中排名第一,其次是 YourDomain.com。如果访问者通过输入 YourDomain.com 到达该站点,那么 CI 会以某种方式“看到”该站点,然后从数据库查询该域的内容。

这有道理吗?还有其他人尝试过吗?是否可以?

I'm sure I'm not the first person who has thought about this but I haven't had any luck forming that proper search query in google to find the info. Here's what I'm wanting to do:

I have a CodeIgniter based site. I'm going to store basic content into tables in the db. I'm thinking that I would have the domain names stored in table to and use the unique id of the table row as the method of querying the appropriate content from the db for the rest of the views. For example. MyDomain.com is #1 in the row followed by YourDomain.com. If the visitor arrived at the site by typing YourDomain.com then somehow CI would "see" that and then query the content for that domain from the db.

Does this make sense? Has anyone else tried it? Is it possible?

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

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

发布评论

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

评论(2

一影成城 2024-12-22 09:18:13

我自己没有这样做,但我搜索了“codeigniter multi site”并找到了一些有用的链接,是其中之一,似乎可以引导您完成整个过程。

Haven't done it myself, but I did some searching for "codeigniter multi site" and found some useful links, this being one of them that seemed to step you through the process.

勿忘初心 2024-12-22 09:18:13

一般来说,有一个 HTTP_HOST 标头(或类似的标头)来标识用户请求中的主机。您可以查看该标头,然后使用它来索引数据库以提取正确的内容。

In general there is an HTTP_HOST header (or similar header) that identifies the host in the user's request. You can look that header up and then use that to index into your database to extract the right content.

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