我的虚拟主机不适用于非 www 版本

我的虚拟主机不适用于非 www 版本

我有一个开发 Web 服务器(ubuntu + apache),可以通过 URL glacialsummit.com 访问。出于某种原因,http://www.glacialsummit.com提供来自 /srv/www/glacialsummit.com/ 目录的页面,但是http://glacialsummit.com提供 /var/www/ 目录中的页面。以下是我的一些虚拟主机配置文件

文件名:/etc/apache2/sites-enabled/glacialsummit.com

<VirtualHost 97.107.140.47:80>
     ServerAdmin [email protected]
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined
</VirtualHost>
<VirtualHost 97.107.140.47:443>
     ServerAdmin [email protected]
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined

        SSLEngine on

        SSLCertificateFile    /etc/ssl/localcerts/www.glacialsummit.com.crt
        SSLCertificateKeyFile /etc/ssl/localcerts/www.glacialsummit.com.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch ".*MSIE.*" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0

</VirtualHost>
<VirtualHost 97.107.140.47:80>
     ServerAdmin [email protected]
     ServerName project.glacialsummit.com
     ServerAlias www.project.glacialsummit.com
     DocumentRoot /srv/www/project.glacialsummit.com/public_html/
     ErrorLog /srv/www/project.glacialsummit.com/logs/error.log
     CustomLog /srv/www/project.glacialsummit.com/logs/access.log combined
</VirtualHost>
## i have many other vhosts that work fine in this file

文件名 /etc/apache2/sites-enabled/000-default

<VirtualHost 97.107.140.47:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

文件名:/etc/apache2/ports.conf

NameVirtualHost 97.107.140.47:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

我该如何http://glacialsummit.com就像从 /srv/www/glacialsummit.com/public_html 提供网页一样http://www.glacialsummit.com

答案1

除任何 VirtualHost 之外,整个服务器的服务器名称是什么?我敢打赌它是glacialsummit.com... 如果是这样,那么它将成为ServerName中未命名 VirtualHost 的000-default.conf,并且此 VirtualHost 将覆盖www.glacialsummit.comVirtualHost。

答案2

ServerAlias *.glacialsummit.com 

使所有内容 (www、非 www 和子域) 都归咎于别名。

答案3

ServerAlias在您的最顶级虚拟主机下,glacialsummit.com添加www.glacialsummit.com

相关内容