0

Essentially I am trying to redirect all traffic to https. My current setup works if I try to connect with any subdomain like www.domain.tld or random.domain.tld. These all redirect to https, however if I try to connect to just domain.tld I get a 404. I am trying to do this purely with Redirect and no Rewrite rules.

I have setup a * CNAME record for all subdomains for my domain. I have the following in my apache configuration for this domain (removed Identifying information):

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias *.domain.tld
    Redirect permanent / https://domain.tld
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/domain.tld/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld/privkey.pem
    ServerName domain.tld
    ServerAlias *.domain.tld
    DocumentRoot /var/www/domain.tld/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Not sure what the issue is and I appreciate the help.

1 Answers1

0

I solved the issue, I needed to add the following to the top of my apache2.conf: Servername X.X.X.X

Replacing the Xs with my IP.