Apache / Letsencrypt - 重定向到 https 不適用於子域

Apache / Letsencrypt - 重定向到 https 不適用於子域

我有一個 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我沒有被重定向,但我確實看到了正確的頁面。

我該如何解決這個問題?

相關內容