问题描述
我正在尝试设置动态虚拟主机,但遇到了一些麻烦.它不允许我设置多个 ServerAlias.
I am trying to set up a dynamic vHost, but have run into some trouble. It will not allow me to set multiple ServerAlias.
<VirtualHost *:80>
ServerAlias *
ServerAdmin michael.ian.curry@gmail
VirtualDocumentRoot /var/www/%1/production/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
上述虚拟主机仅适用于",我需要它才能用于www."和*"我认为将 ServerAlias 设置为可以修复它,但它不起作用.
The above vHost only works for '' i need it to work for 'www.' and '*' I assumed that setting the ServerAlias to would fix it, but it is not working.
ServerAlias * www.*
如果您有任何见解,请回复
If you have any insight, please respond
--迈克尔库里
==编辑 1==
例如 redcrusher 和 www.redcrusher
Example redcrusher and www.redcrusher
==编辑 2==
下面的代码也不起作用
ServerAlias www.* *
推荐答案
想通了!
'www.*' 必须在 '*' 之前执行 这是因为 ServerAlias 正在设置一个动态域,并且必须在较小"别名存在之前存在.
'www.*' must execute before '*' This is because ServerAlias is setting a dynamic domain and must exist before a "smaller" alias exists.
示例:'www.*'、'dev.*'、'asdf.*' THEN '*'
Example: 'www.*', 'dev.*', 'asdf.*' THEN '*'
虚拟主机文件 [production.conf]:
vHost File [production.conf]:
<VirtualHost *:80>
ServerAlias www.*
VirtualDocumentRoot /var/www/%2/production/html
ServerAdmin michael.ian.curry@gmail
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
<VirtualHost *:80>
ServerAlias *
VirtualDocumentRoot /var/www/%1/production/html
ServerAdmin michael.ian.curry@gmail
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
我希望这可以帮助其他遇到此问题的人!
I hope this helps anyone else that is having this problem!
--迈克尔库里
这篇关于具有多个 ServerAlias 的 Apache2 动态虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论