CodeIgniter 如何使用一个 CMS 创建多个站点
我想创建一个只有一个 CMS 的博客网站。此 CMS 将位于不同的域中。
例如:mycms.com
然后我的博客网站也在不同的域中。
例如:website1.com、website2.com、website3.com
他们都将使用 mycms.com 作为他们的管理员
*图像将上传到 mycms.com/images/,因此所有 3 个网站将从该目录获取图像
如果图像从主数据库加载到 website1.com 上,它们应该显示为来自 website1.com。例如,website1.com/images/cat.jpg 而不是 mycms.com/images/cat.jpg
我将如何使用 codeigniter 构建它?
I want to create a blog site with only one CMS. This CMS will be in different domain.
For example: mycms.com
Then my blog sites are also in different domains.
For example: website1.com, website2.com, website3.com
They will all use mycms.com as their admin
*Images will be uploaded in mycms.com/images/ so all the 3 websites will get the images from this directory
If images are loaded on website1.com from the main database, they should be displayed as if they're from website1.com. So for example website1.com/images/cat.jpg instead of mycms.com/images/cat.jpg
How will I build this using codeigniter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您愿意,您可以对所有网站使用相同的 CodeIgniter /System 和 /Application 文件夹;只需确保所有
index.php
文件都设置为分别使用$system_path
和$application_folder
的相同文件夹即可。请注意,这些站点还需要驻留在同一服务器上。您可以通过检查请求来自的域的
$_SERVER['HTTP_HOST']
来提供不同的内容。至于 htaccess,您应该能够使用
%{HTTP_HOST}/$1
或%{HTTP_HOST}$1
(取决于服务器配置)使重写规则动态化。我实际上正在使用 CodeIgniter 构建一个类似的项目,但也有 其他几个可用的项目,例如 halogy、codefight、pyro(带扩展)等等。
You can use the same CodeIgniter /System and /Application folders for all the websites if you like; just make sure all the
index.php
files are setup to use those same folders for$system_path
and$application_folder
respectively. Note that these sites also need to reside on the same server.You can serve up different content by checking
$_SERVER['HTTP_HOST']
for the domain the request came from.As for htaccess you should be able to use
%{HTTP_HOST}/$1
or%{HTTP_HOST}$1
(depending on server config) to make the rewrite rule dynamic.I am actually building a similar project right now using CodeIgniter but there are also several other projects available like halogy, codefight, pyro (with an extension), and many others.
CodeIgniter 有一个 System 和一个 Application 文件夹。您可以拥有一个全局系统文件夹,然后为每个子域拥有一个应用程序文件夹,或者您可以拥有一个应用程序文件夹,然后将子域文件夹与 www 文件夹平行。
CodeIgniter has a System and an Application folder. You could have one global system folder and then one application folder for each of your subdomains, or you could have one application folder and just make your subdomian folders parallel with your www folder.