1

I have a 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. Secure means it will redirect to https no matter what.

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.

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:

<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

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

Ofcourse when I go to https://school.luukwuijster.eu I am not redirected, but I do see the right page.

How do I solve this problem?

7

0

You must log in to answer this question.

Browse other questions tagged .