apache virtualhost子域问题

时间:2018-10-26 19:37:49

标签: apache subdomain virtualhost

我在带有LAMP堆栈的centos 5.10上有一个运行VPS的Apache。
我在此框中有多个域,它们通过VirtualHost路由到.conf文件中。

当我进入浏览器并输入虚假的子域时,例如aa.mynewco.com
我得到一个页面,上面写着Your connection is not private,即使我在该服务器名上没有设置和子域,它也可以继续进行。当我继续时,它将带我到companyname.com

但是当我在aa.companyname.com上尝试相同的伪造子域时
我得到This site can’t be reached

如何防止伪造的子域?为什么mynewco.com进行到companyname.com

ServerName  localhost

<VirtualHost *:80>
      DirectoryIndex index.html index.php
      ServerName www.dev.companyname.com
      ServerAlias dev.companyname.com
      ServerAdmin abc@yahoo.com  
      DocumentRoot "/var/www/html/dev.companyname"
      <Directory /var/www/html/dev.companyname>
              Options FollowSymLinks
              AllowOverride All
              Allow from all
      </Directory>
</VirtualHost>
<VirtualHost *:80>
        DirectoryIndex index.html index.php
        ServerName www.companyname.com
        ServerAlias companyname.com
        ServerAdmin abc@yahoo.com  
        DocumentRoot "/var/www/html/companyname"
        <Directory /var/www/html/companyname >
                Options FollowSymLinks
                AllowOverride All
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost *:443>
    DirectoryIndex index.html index.php
    ServerAdmin abc@yahoo.com          
    DocumentRoot /var/www/html/companyname
    ServerName www.companyname.com
    ErrorLog /var/log/conf.log
    SSLEngine on
    SSLProtocol all
    SSLCertificateFile /etc/pki/tls/certs/companyname_public.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/companyname_private.key
    SSLCertificateChainFile /etc/pki/tls/certs/companyname_intermediate.crt
    <Directory "/var/www/html/companyname">
        Options FollowSymLinks
    </Directory>
</VirtualHost>


<VirtualHost *:80>
        DirectoryIndex index.html index.php
        ServerName www.mynewco.com
        ServerAlias mynewco.com
        ServerAdmin abc@yahoo.com  
        DocumentRoot "/var/www/html/mynewco"
        <Directory /var/www/html/mynewco >
                Options FollowSymLinks
                AllowOverride All
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost *:443>
    DirectoryIndex index.html index.php
    ServerAdmin abc@yahoo.com          
    DocumentRoot /var/www/html/mynewco
    ServerName www.mynewco.com
    ErrorLog /var/log/conf.log
    SSLEngine on
    SSLProtocol all
    SSLCertificateFile /etc/pki/tls/certs/mynewco_public.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/mynewco_private.key
    SSLCertificateChainFile /etc/pki/tls/certs/mynewco_intermediate.crt
    <Directory "/var/www/html/mynewco">
        Options FollowSymLinks
    </Directory>
</VirtualHost>

此帖子回答了我的问题: https://serverfault.com/questions/727055/redirect-all-subdomains-to-main-domain-inside-vhost?newreg=df0c95126aa0409f9b71ec6a116c876a

0 个答案:

没有答案