我有一个包含以下内容的虚拟主机文件:
# lc.glsamcrm.com
#
<VirtualHost *:80>
ServerAdmin webmaster@lc.glsamcrm.com
ServerName lc.glsamcrm.com
ServerAlias glsamcrm.com
DirectoryIndex index.html
DocumentRoot /var/www/glsamcrm/htdocs/
ErrorLog /var/www/glsamcrm/logs/error.log
CustomLog /var/www/glsamcrm/logs/access.log combined
ServerAdmin webmaster@crm.glstest.com
ServerName crm.glstest.com
ServerAlias crm.glstest.com
DirectoryIndex index.html
DocumentRoot /var/www/glsamcrm_prod/htdocs/
ErrorLog /var/www/glsamcrm_prod/logs/error.log
CustomLog /var/www/glsamcrm_prod/logs/access.log combined
</VirtualHost>
当我将浏览器指向lc.glsamcrm.com时,一切正常。当我将浏览器指向crm.glstest.com时,我得到位于etc / www /文件夹中的“THIS WORKS”索引页面。发生了什么事?
答案 0 :(得分:2)
您需要两个单独的VirtualHost指令。这是因为每个VirtualHost只能放一个ServerName,DocumentRoot和其他几个。
<VirtualHost *:80>
ServerAdmin webmaster@lc.glsamcrm.com
ServerName lc.glsamcrm.com
ServerAlias glsamcrm.com
DirectoryIndex index.html
DocumentRoot /var/www/glsamcrm/htdocs/
ErrorLog /var/www/glsamcrm/logs/error.log
CustomLog /var/www/glsamcrm/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@crm.glstest.com
ServerName crm.glstest.com
ServerAlias crm.glstest.com
DirectoryIndex index.html
DocumentRoot /var/www/glsamcrm_prod/htdocs/
ErrorLog /var/www/glsamcrm_prod/logs/error.log
CustomLog /var/www/glsamcrm_prod/logs/access.log combined
</VirtualHost>