apache 多个域到一个虚拟主机 | 通配符主机(共享主机)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/621819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple Domains to One Virtual Host | Wildcard Host (shared hosting)?
提问by Codex73
I have the following task: Create one website which is accessible with 20 different domains names.
我有以下任务:创建一个可以使用 20 个不同域名访问的网站。
Same files, same folder, same ip.
相同的文件,相同的文件夹,相同的IP。
Question (shared hosting):Can this be accomplish with a bare cname's pointing to the same common subdomain or do we need one static ip for all?
问题(共享主机):这可以通过指向同一个公共子域的裸 cname 来完成,还是我们需要一个静态 IP?
The problem is sure shared hosting and I'm trying to avoid creating manually "cpanel addon domains" one by one. Shared hosting doesn't allow to modify httpd conf which allows me to create a wildcard virtual host for an IP.
问题肯定是共享主机,我试图避免一个一个地手动创建“cpanel 插件域”。共享主机不允许修改 httpd conf,这允许我为 IP 创建通配符虚拟主机。
I guess my question is auto answered; I'll need a static unless I'm only using subdomain's w wildcard, which works on shared hosting. "*.domain.com", "two.domain.com", "three.domain.com" => directory/
我想我的问题是自动回答的;我需要一个静态的,除非我只使用子域的 w 通配符,它适用于共享主机。"*.domain.com", "two.domain.com", "three.domain.com" => 目录/
回答by Paul Dixon
I think you have answered your own question, the options open to you are
我想你已经回答了你自己的问题,你可以选择的选项是
- Add ServerAlias entries to the vhost config, via whatever means available to you
- Ensure the default virtual host on the target IP is the one which handles your site
- 通过任何可用的方式将 ServerAlias 条目添加到 vhost 配置
- 确保目标 IP 上的默认虚拟主机是处理您站点的主机
回答by Alnitak
If you use a CNAME (or indeed an A record pointing to the same IP address) then you must, as Paul says, either have
ServerAliasentries inhttpd.conf, or point them at thedefaultvirtual hostIf you can't do that, host 19 of the domain names at some other web host, and then use HTTP redirect to get users to the "preferred" domain name. However if you do this then the domain name will change in the user's address bar.
如果您使用 CNAME(或者实际上是指向相同 IP 地址的 A 记录),那么您必须,正如 Paul 所说,要么在 中包含
ServerAlias条目,要么将httpd.conf它们指向default虚拟主机如果您不能这样做,请在其他 Web 主机上托管 19 个域名,然后使用 HTTP 重定向让用户访问“首选”域名。但是,如果您这样做,那么用户地址栏中的域名将发生变化。

