-1

My virtual host file:

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com

#Redirect non-https or non-www to https://www...
RewriteEngine On
#NOT TESTING HTTPS REDIRECTION FOR NOW
#RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,NE,R=301]
</VirtualHost>

The conf file for SSl is the default one by letsencrypt.

My tests so far, first 3 results are expected, last is not

decimoseptimo@ubuntu-512mb-sfo2-1:~$ curl -I http://example.com                                                 
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/

301

decimoseptimo@ubuntu-512mb-sfo2-1:~$ curl -I http://www.example.com
HTTP/1.1 200 OK

OK

decimoseptimo@ubuntu-512mb-sfo2-1:~$ curl -I https://www.example.com
HTTP/1.1 200 OK

OK

decimoseptimo@ubuntu-512mb-sfo2-1:~$ curl -I https://example.com
HTTP/1.1 200 OK

OK

Seems www redirection is not occuring over SSL! no idea why, apache was restarted since last configuration editing.

Any thoughts?

1 Answers1

0

The last two tests would match the 443 VirtualHost. You have not included that in the question, but we can assume that there is not a matching RewriteCond/Rule pair in the 443 VirtualHost.

Joe
  • 1,053