做虚拟主机的定义我需要支持subdomain.mydomain.com和* .mydomain.com来在同一个IP地址在Apache 2? [英] What Virtual Host Definitions do I need to support subdomain.mydomain.com and *.mydomain.com on the same IP Address on Apache 2?

查看:291
本文介绍了做虚拟主机的定义我需要支持subdomain.mydomain.com和* .mydomain.com来在同一个IP地址在Apache 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Apache 2的虚拟主机设置,像这样(简体):

I have a virtual host setup on Apache 2 like so (simplified):

<VirtualHost *>
  ServerName domain.com
  ServerAlias *.domain.com
  DocumentRoot /var/www/domain.com/html
</VirtualHost>

<VirtualHost sub1.domain.com>
  ServerName sub1.domain.com
  DocumentRoot /var/www/sub1.domain.com/html
</VirtualHost>

<VirtualHost sub2.domain.com>
  ServerName sub2.domain.com
  DocumentRoot /var/www/sub2.domain.com/html
</VirtualHost>

我在寻找的结果是一切,是不是sub2.domain.com或sub1.domain.com应该去domain.com。他们都必须是同一个缺省端口上,他们都共享同一个IP地址。

The outcome I'm looking for is everything that isn't sub2.domain.com or sub1.domain.com should go to the domain.com. They all have to be on the same default port and they all share the same IP address.

什么真正发生的是SUB2去SUB2不如预期,以及其他一切去SUB1,即通配符定义将被忽略。

What actually happens is that sub2 goes to sub2 as expected, and everything else goes to sub1, i.e. the wildcard definition is ignored.

我怎样才能解决这个问题呢?

How can I fix this up?

谢谢!

推荐答案

更改的&lt;虚拟主机sub1.domain.com&GT;到&lt;虚拟主机* GT;和
&LT;虚拟主机sub2.domain.com&GT;到&lt;虚拟主机* GT;也。第一个是默认的反正。

Change the <VirtualHost sub1.domain.com> to <VirtualHost *> and <VirtualHost sub2.domain.com> to <VirtualHost *> also. First one is the default one anyway.

这篇关于做虚拟主机的定义我需要支持subdomain.mydomain.com和* .mydomain.com来在同一个IP地址在Apache 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆