对于多虚拟主机的httpd多个别名 [英] Multiple Aliases for Multiple vhosts httpd

查看:168
本文介绍了对于多虚拟主机的httpd多个别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的任何域指向一个CNAME在我的虚拟主机作为,我使用

  ServerAlias​​ *

在我的虚拟主机,但如果我在两个CNAME指向第二个虚拟主机服务从第一虚拟主机自得添加它只是一个虚拟主机的作品。

 例如:
1:files.domain.com CNAME到files.example.com
第二:r.domain.com CNAME到r.example.com

但第二个也提供files.example.com

我的的httpd.conf 有这两个虚拟主机

 <虚拟主机*:80>
    的ServerAdmin admin@example.com
    DocumentRoot的/var/www/files.example.com
    服务器名files.example.com
    错误日志/var/www/files.example.com/logs/error_log
    的CustomLog /var/www/files.example.com/logs/custom_log常见
    <目录/var/www/files.example.com\">
        有FollowSymLinks
        所有的AllowOverride        为了允许,拒绝
        所有允许
    < /目录>
< /虚拟主机><虚拟主机*:80>
    的ServerAdmin admin@example.com
    DocumentRoot的/var/www/r.example.com
    服务器名r.example.com
    错误日志/var/www/r.example.com/logs/error_log
    的CustomLog /var/www/r.example.com/logs/custom_log常见
    <目录/var/www/r.example.com\">
        有FollowSymLinks
        所有的AllowOverride        为了允许,拒绝
        所有允许
    < /目录>
< /虚拟主机>


解决方案

我通过我想要的虚拟主机设置一个专用的IP解决了这个问题在 ServerAlias​​ 是*和它的工作。

 <虚拟主机192.168.1.55:80>
    的ServerAdmin admin@example.com
    DocumentRoot的/var/www/r.example.com
    服务器名r.example.com
    ServerAlias​​ *
    错误日志/var/www/r.example.com/logs/error_log
    的CustomLog /var/www/r.example.com/logs/custom_log常见
    <目录/var/www/r.example.com\">
        有FollowSymLinks
        所有的AllowOverride        为了允许,拒绝
        所有允许
    < /目录>
< /虚拟主机>

I want any domain to point a CNAME on my vhosts for that i use

ServerAlias *

in my vhosts but it only works with one vhost if I add it in both the CNAME pointed to the second vhost serves the contented from the first vhost.

e.g:
1st: files.domain.com CNAME to files.example.com
2nd: r.domain.com CNAME to r.example.com

but second one is also serving files.example.com

My httpd.conf has these two vhosts

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/files.example.com
    ServerName files.example.com
    ErrorLog /var/www/files.example.com/logs/error_log
    CustomLog /var/www/files.example.com/logs/custom_log common
    <Directory "/var/www/files.example.com">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/r.example.com
    ServerName r.example.com
    ErrorLog /var/www/r.example.com/logs/error_log
    CustomLog /var/www/r.example.com/logs/custom_log common
    <Directory "/var/www/r.example.com">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

解决方案

I solved this problem by setting a dedicated ip on the vhost where I want the ServerAlias to be * and it worked

<VirtualHost 192.168.1.55:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/r.example.com
    ServerName r.example.com
    ServerAlias *
    ErrorLog /var/www/r.example.com/logs/error_log
    CustomLog /var/www/r.example.com/logs/custom_log common
    <Directory "/var/www/r.example.com">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

这篇关于对于多虚拟主机的httpd多个别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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