一台服务器,多个域,共享PHP MVC
我想生成 php 驱动的网站的区域版本,例如:
www.mysite-england.co.uk
www.mysite-wales.co.uk
www.mysite-scotland.co.uk
我想设置一台 LAMP 服务器,使用 $_SERVER['HTTP_HOST']
(或类似)作为主要内容修饰符。即,
if($_SERVER['HTTP_HOST'] == 'mysite-wales.co.uk'){
$region = 'wales';
$database = 'db_wales';
$styles= array('wales.css', 'wales_banners.css')
etc etc....
}
我如何设置服务器以将所有这些域定向到单个服务器上的同一个 MVC 路由器?
I'd like to produce regional versions of a php powered website, for example:
www.mysite-england.co.uk
www.mysite-wales.co.uk
www.mysite-scotland.co.uk
I'd like to setup one LAMP server to serve all the domains with a single php MVC using $_SERVER['HTTP_HOST']
(or similar) as the primary content modifier. Ie
if($_SERVER['HTTP_HOST'] == 'mysite-wales.co.uk'){
$region = 'wales';
$database = 'db_wales';
$styles= array('wales.css', 'wales_banners.css')
etc etc....
}
How do i go about setting up the server to direct all these domains to the same MVC router on a single server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为主站点配置 Apache 虚拟主机,并使用 ServerAlias 指令,以便它接受其他域的连接。
更多信息:
Configure the Apache virtual host for the main site, and use the ServerAlias directive so it accepts connections for your other domains.
More information:
在我上一份工作中,我们经常这样做。您所做的就是在虚拟主机中将所有域指向同一代码库。代码库不会关心差异是什么,除非您定义变量(IE 站点名称、区域)。只需将服务器别名添加到您的虚拟主机并在引导程序顶部运行一个开关即可。
We did this a lot at my last job. All you do is in the vhost point all the domains at the same code base. The code base will not care what the difference is except where you define variables (I.E. Site Name, Region). Just add the server aliases to your vhost and run a switch at the top of your bootstrap.