I have created an SSL certificate using Let's Encrypt.
The certificate has been installed and is referenced in the Apache config file.
The Apache config provides a ServerName (e.g., example.com) and a ServerAlias (e.g., www.example.com). Both are referenced in the SSL certificate as verified by the output from the certbot certificates command.
The Apache config also contains a redirect from HTTP to HTTPS.
RedirectMatch permanent ^/(.*) https://example.com/$1
The problem is that the redirect is only happening for the alias (www.example.com). Requests to example.com result in a simple 200 OK response.
Request to alias:
$ curl -I www.example.com HTTP/1.1 301 Moved Permanently Date: Sun, 01 Mar 2020 19:13:57 GMT Server: Apache/2.4.29 (Ubuntu) Location: https://example.com/ Content-Length: 325 Content-Type: text/html; charset=iso-8859-1 Request to the actual ServerName value:
curl -I example.com HTTP/1.1 200 OK Date: Sun, 01 Mar 2020 19:16:43 GMT Server: Apache/2.4.29 (Ubuntu) Last-Modified: Sun, 23 Feb 2020 00:03:31 GMT ETag: "2aa6-59f32fc296ba5" Accept-Ranges: bytes Content-Length: 10918 Vary: Accept-Encoding Content-Type: text/html The <VirtualHost *:80> and <VirtualHost *:443> sections of the config file are identical except for the redirect in the *:80 section and the SSL lines in the *:443 section:
SSLCertificateFile /etc/letsencrypt/live/example/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf Am I missing something obvious or have I just gone far awry? :-) Thanks