我有一台 Ubuntu 16.04 VPS。我使用 Letsencrypt 作为我的 SSL 证书,在创建或创建证书时,他们会询问您是否需要轻松访问或安全访问。安全意味着无论如何它都会重定向到 https。
这在主页上有效,但在子域上无效。我没有重定向到 https,我只看到我的 index.html,只是 apache 默认页面。
那么我该如何解决这个问题?
我的虚拟主机:
<VirtualHost *:80>
ServerName school.luukwuijster.eu
Redirect / https://school.luukwuijster.eu
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/school.luukwuijster.eu/public/
<Directory /var/www/html/school.luukwuijster.eu/public/>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =school.luukwuijster.eu
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
le-ssl:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName school.luukwuijster.eu
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/school.luukwuijster.eu/public/
<Directory /var/www/html/school.luukwuijster.eu/public/>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =school.luukwuijster.eu
# Some rewrite rules in this file were were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/luukwuijster.eu-0003/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/luukwuijster.eu-0003/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
由于某种原因,它只是没有重定向。
当我去http://luukwuijster.eu我被重定向到https://luukwuijster.eu
这样就可以了,但是当我去http://school.luukwuijster.eu我并没有被重定向,而是看到了与https://luukwuijster.eu
当然,当我去https://school.luukwuijster.eu我没有被重定向,但我确实看到了正确的页面。
我该如何解决这个问题?