[英]Apache / Letsencrypt - redirecting to https not working on subdomains
I have a Ubuntu 16.04 VPS. 我有一个Ubuntu 16.04 VPS。 I use Letsencrypt for my ssl certificates, when creating or creating a certificate, they ask if you want easy or secure access.
我将Letsencrypt用于我的ssl证书,在创建或创建证书时,他们会询问您是否希望轻松或安全地访问。 Secure means it will redirect to https no matter what.
安全意味着无论如何它都会重定向到https。
This works on the homepage, but it doesn't work on the subdomains. 这在首页上有效,但在子域上无效。 I am not redirected to https, and I just see my index.html whats just the apache default page.
我没有重定向到https,而我仅看到我的index.html,只是apache默认页面。
So how do I fix this? 那么我该如何解决呢?
My Virtualhost: 我的虚拟主机:
<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: 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>
For some reason its just not redirecting. 由于某种原因,它只是不重定向。
When I go to http://luukwuijster.eu I am redirected to https://luukwuijster.eu 当我转到http://luukwuijster.eu时,我被重定向到https://luukwuijster.eu
So that works fine, but when I go to http://school.luukwuijster.eu I am not redirected and get to see the same page as on https://luukwuijster.eu 这样就可以了,但是当我转到http://school.luukwuijster.eu时,我没有被重定向到与https://luukwuijster.eu相同的页面。
Ofcourse when I go to https://school.luukwuijster.eu i am not redirected, but I do see the right page. 当然,当我转到https://school.luukwuijster.eu时,我没有重定向,但确实看到了正确的页面。
How do I solve this problem? 我该如何解决这个问题?
Try to change line 3 from Redirect / https://school.luukwuijster.eu
to RedirectPermanent / https://school.luukwuijster.eu/
. 尝试将第3行从
Redirect / https://school.luukwuijster.eu
更改为RedirectPermanent / https://school.luukwuijster.eu/
。
BTW currently your SSL cert is only valid for api.luukwuijster.eu. 顺便说一句,当前您的SSL证书仅对api.luukwuijster.eu有效。 You should add school.luukwuijster.eu and all other domains you want to secure to your letsencrypt config.
您应该将school.luukwuijster.eu以及所有要保护的其他域添加到letencrypt配置中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.