简体   繁体   English

CentOS Apache VirtualHost默认

[英]CentOS Apache VirtualHost default

I have set up some virtal host to distinguish between my subdomains (/etc/httpd/conf.d/*.conf). 我已经设置了一些虚拟主机来区分我的子域(/etc/httpd/conf.d/*.conf)。

This was working on my old server (Debian 7). 这正在我的旧服务器(Debian 7)上运行。 But now if I browse the root page I get the first defined VirtualHost displayed. 但是现在,如果我浏览根页面,则会显示第一个已定义的VirtualHost。

Also if I am browsing an undefined subdomain I get the first VirtualHost config displayed. 另外,如果我正在浏览未定义的子域,则会显示第一个VirtualHost配置。

<VirtualHost *:80>

    ServerAdmin admin@example.com

    ServerName sub1.example.com
    ServerAlias sub1.example.com
    DocumentRoot /home/sub/sub_sub1/www
    ServerAdmin Admin
    CustomLog /home/sub/sub_sub1/logs/access.log combined
    ErrorLog /home/sub/sub_sub1/logs/error.log
    LogLevel warn

    <Directory /home/sub/sub_sub1/www>
        Require all granted
    </Directory>

</VirtualHost>

The first defined VirtualHost will serve all the requests that don't get handled by the other ones. 第一个定义的VirtualHost将处理其他请求未处理的所有请求。 You can create a default VirtualHost that handles those requests. 您可以创建一个默认的VirtualHost来处理这些请求。 To make sure this VirtualHost is the first one, you should name its config-file something like "000-default.conf". 为了确保此VirtualHost是第一个,您应将其配置文件命名为“ 000-default.conf”。

This might also help you: VirtualHost Examples 这也可能对您有帮助: VirtualHost示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM