![SSL 文件夹重定向问题 - ubuntu 16.04/Apache 2.4](https://linux22.com/image/700056/SSL%20%E6%96%87%E4%BB%B6%E5%A4%B9%E9%87%8D%E5%AE%9A%E5%90%91%E9%97%AE%E9%A2%98%20-%20ubuntu%2016.04%2FApache%202.4.png)
我们已经为网站启用了 SSL。如果我们输入“https://example.com/“(使用 htpps://),它指向正确的文件夹。没有https://(example.com)它指向根文件夹 (/var/www/html)。如何将两者都指向正确的文件夹“/var/www/html/example.com/public_html”?
.conf如下
<Directory /var/www/html/example.com/public_html>
Require all granted
</Directory>
<VirtualHost xx.xx.xx.xx:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/example.crt
SSLCertificateKeyFile /etc/apache2/ssl/example.key
SSLCACertificateFile /etc/apache2/ssl/example.cer
ServerName example.com
ServerAlias www.example.com
ServerAdmin test@example
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
</VirtualHost>
答案1
将以下内容添加到配置中即可(除非ServerName
或ServerAlias
具有值的指令example.com
已经在 VHost 中的某处定义):
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin test@example
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
</VirtualHost>