1

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:

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!

Berk
  • 45
  • 9
  • @Machavity I have seen that post, but unfortunately it doesn't provide a solution for redirect from https:// non-www to https:// www – Berk Oct 16 '17 at 21:16
  • Well, [this question covers that](https://stackoverflow.com/questions/16200501/http-to-https-apache-redirection) – Machavity Oct 16 '17 at 23:09
  • I guess I will write again. I want to fix my issue with https:// non-www to https:// www . You are showing separate topics on www redirect and https redirect but when I combined these solutions to accomplish both at the same time I found out the scenario for redirecting https:// non-www to https:// www is not working. Now please leave it to others.... – Berk Oct 16 '17 at 23:17
  • You mean like [this question](https://stackoverflow.com/questions/39683292/apache-redirection-of-both-http-to-https-and-non-www-to-www)? – Machavity Oct 16 '17 at 23:33
  • Third time is the charm. You are right, I am pretty sure that is the correct answer but unfortunately it didn't work for me. It seems to me RewriteCond and RewriteRule has absolutely no effect on my server. I have even tried redirecting to another site, it just ignores it. Trying to debug.. but thanks for the step in right direction – Berk Oct 17 '17 at 01:06
  • actually I realized whole Virtualhost *:443 section has no effect on server. deleted it and it works the same – Berk Oct 17 '17 at 02:05

0 Answers0