I am trying to send all traffic to https://www.example.com without using RewriteEngine, because it is a heavy solution.
I realize there are solutions out there for my problem involving .htaccess file but I am trying to do this in apache.conf in /apache2/sites-enabled
Behavior now:
- www.example.com redirects to https://www.example.com
- example.com redirects to https://www.example.com
- https://example.com doesn't redirect (this is the problem: I want this to redirect to https://www.example.com)
UPDATE: It seems to me that Virtualhost *:443 doesn't change anything in the below conf file, I have played around with 433 sections but they don't effect the behavior on server at all.
Here is my apache.conf:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
.
.
.
Redirect 301 / https://www.example.com/
</VirtualHost>
<VirtualHost *:443> #added this part to fix the issue but it didn't help
ServerName example.com
Redirect 301 / https://www.example.com/
.
.
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
.
.
</VirtualHost>
Also, it would be great to know if there is any risks/inefficiency related to this approach.
I appreciate all your comments!