【问题标题】:Apache Virtual host response with a wrong pageApache 虚拟主机响应错误的页面
【发布时间】:2020-04-15 06:58:18
【问题描述】:

我是一个新手,尝试在 Ubuntu 19.10 上使用 Apache2 托管一个网站。

主站点 - /var/www/main/index.html

apache.conf

<Directory /var/www>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
<Directory>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

ports.conf

Listen 80 
<IfModule ssl_module>
    Listen 443
</IfModule>
  
<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

main.conf

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/main
    SSLEngine on
    SSLProtocol -all +TLSv1.2
    SSLCertificateKeyFile /usr/local/ssl/www.main.com.key
    SSLCertificateFile /usr/local/ssl/www.main.com.crt
    SSLCertificateChainFile /usr/local     /ssl/www.main.com.intermediate.crt
    LogLevel info ssl:warn
    ErrorLog /var/www/error_log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

到目前为止 - 一切正常。

子域站点 - /var/www/sub/index.html

sub.conf

<VirtualHost *:80>   
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/sub
    ServerName sub.main.com
    LogLevel info ssl:warn
    ErrorLog /var/www/error_sub_log
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</virtualHost>

这是主要问题。

为什么很好(abc.main.com)?我的浏览器显示的内容与 sub.main.com 相同。似乎我可以输入任何内容,例如xyz.main.com 和我仍然得到 sub.main.com 的内容。为了解决这个问题,我需要做什么?

【问题讨论】:

    标签: apache ubuntu virtualhost


    【解决方案1】:

    因为 abc.main.com 不存在;因此,sub.main.com html 页面成为默认页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 2015-10-22
      • 2011-06-19
      • 2014-08-12
      • 2016-07-08
      • 2020-09-04
      • 2021-03-28
      相关资源
      最近更新 更多