文档根目录设置不正确

文档根目录设置不正确

我设置了两个虚拟主机,配置文件如下:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerName a.b.com
                ServerAlias https://a.b.com a.b.com https://www.a.b.com
                ServerAdmin [email protected]
                DocumentRoot /var/www/html/
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile      /usr/local/ssl/crt/veneratech.crt
                SSLCertificateKeyFile /usr/local/ssl/crt/veneratech.key
                SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

        </VirtualHost>

       <VirtualHost _default_:443>
                ServerName api.b.com
                ServerAlias https://api.b.com api.b.com https://www.api.b.com
                ServerAdmin [email protected]
                DocumentRoot /var/www/html/apibroker/
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile      /usr/local/ssl/crt/veneratech.crt
                SSLCertificateKeyFile /usr/local/ssl/crt/veneratech.key
                SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

     </VirtualHost>

</IfModule>

当用户打开 时,我希望触发api.b.com下的索引文件。但它始终无法到达,而是直接进入。这可能是什么原因造成的?/var/www/html/apibroker//var/www/html/apibroker//var/www/html/

我编辑了下面的文件/etc/apache2/sites-available/default-ssl.conf,然后将其复制到/etc/apache2/sites-enabled

此外,如何通过文件实现这一点.htaccess

答案1

尝试将虚拟主机块更改为:

 <VirtualHost *:443>

此外,您可能应该设置两个完全独立的文档根,如下所示:

用来a.b.com

 DocumentRoot /var/www/html/main_site/

用来api.b.com

 DocumentRoot /var/www/html/api_site/

相关内容