虚拟主机通配符域和子域静 [英] Virtualhost For Wildcard Subdomain and Static Subdomain

查看:139
本文介绍了虚拟主机通配符域和子域静的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的情况下,我想有网址 app1.example.com example.com *。example.com 全部使用不同的虚拟主机。这是我(不包括 example.com 的原因,它只是使混乱)

 <虚拟主机* GT;
  服务器名app1.example.com
  ServerAlias​​ app1.example.com   的DocumentRoot = /无功/网络/ APP1
   #为这个应用程序在这里其他配置< /虚拟主机><虚拟主机* GT;
  服务器名wildcard.example.com
   ServerAlias​​ * .example.com的   的DocumentRoot = /无功/网络/通配符
   #为这个应用程序在这里的其他配置< /虚拟主机>

的问题是,它们的冲突。哪一个首先列出胜出。我怎么能同时承载通配符虚拟主机和特定的?

请注意:我不只是改变的DocumentRoot 在配置,因此,使用的mod_rewrite 来改变DocumentRoot的变量不解决这个问题。

感谢


解决方案

 <虚拟主机*:80>
  的DocumentRoot的/ var / WWW / APP1
  服务器名app1.example.com
< /虚拟主机><虚拟主机*:80>
  DocumentRoot的/无功/网络/例子
  服务器名称example.com
< /虚拟主机><虚拟主机*:80>
  的DocumentRoot的/ var / WWW /通配符
  服务器名other.example.com
  ServerAlias​​ * .example.com的
< /虚拟主机>

应该工作。第一个条目将成为默认的,如果你没有得到一个明确的匹配。所以,如果你有app.otherexample.com指向它,将它的BE app1.example.com捕获。你需要根据虚拟主机打开名的第一项。

I have an odd situation where I want to have the urls app1.example.com, example.com and *.example.com all using a different virtual host. This is what I have (excluding example.com cause it just makes it messier)

<VirtualHost *>
  ServerName app1.example.com
  ServerAlias app1.example.com

   DocumentRoot = /var/www/app1
   # Other configuration for this app here

</VirtualHost>

<VirtualHost *>
  ServerName wildcard.example.com
   ServerAlias *.example.com

   DocumentRoot = /var/www/wildcard
   # other configuration for this app here

</VirtualHost>

The problem is that they conflict. Whichever one is listed first wins out. How can I host both a wildcard virtualhost and a specific one?

Note: I'm not just changing DocumentRoot in the config, so using mod_rewrite to change the DocumentRoot variable does not fix it.

Thanks

解决方案

<VirtualHost *:80>
  DocumentRoot /var/www/app1
  ServerName app1.example.com
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /var/www/example
  ServerName example.com
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /var/www/wildcard
  ServerName other.example.com
  ServerAlias *.example.com
</VirtualHost>

Should work. The first entry will become the default if you don't get an explicit match. So if you had app.otherexample.com point to it, it would be caught be app1.example.com. You need to turn on the name based virtual hosts with the first entry.

这篇关于虚拟主机通配符域和子域静的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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