0

I have a file www.example.org.conf that I want to redirect http to https. The problem is the file doesn't exactly work right.

<VirtualHost *:80>
        ServerName example.org
        ServerAlias www.example.org
        DocumentRoot "/var/www/example.org/www"
        CustomLog /var/www/example.org/www.access.log common
        ErrorLog /var/www/example.org/www.error.log
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.org [OR]
RewriteCond %{SERVER_NAME} =www.example.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

The redirect was actually automatically generated from letsencrypt, but here's the problem.

Typing in http://www.example.org will redirect to https://www.example.org, as intended.

The problem is when you type in http://example.org, where it will show the apache default page instead of redirecting to https.

I can verify the SSL conf working when I type in https://example.org or https://www.example.org, which shows the page I want. Therefore I have concluded that the problem is in the mod_rewrite. However, I do not know what is wrong. In fact, my other VirtualHosts that follow the same structure works as intended.

Please help me figure out what is wrong with my site configs. I'm using apache2 with Debian by the way.

1 Answers1

3

This commonly occurs because your 000-default website, which automatically enables itself when apache2 is installed on a Debian server, is enabled. Check to see if 000-default is enabled.

KTOmega
  • 56
  • 3