I have trouble redirecting http to https!! I'm trying to apply advices but none of them is working.
now I have main domain and sub domains such as example.com / sub1.example.com / sub2.example.com
when I access via https://example.com, It works well but when I type just example.com or www.example.com or http://example.com, it goes 301 code and then load error.html.var
error.html.var is default ErrorDocument on httpd.config However, there is no config for 301 error code but I have no idea loading err.html.var for 301 code
I use httpd.conf / httpd-vhosts.conf / ssl.conf
on httpd-vhosts.conf
Listen 80
Listen 443
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
it goes 301 code and then load error.html.var
so I've tried
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName sub1.example.com
Redirect permanent / https://sub1.example.com/
</VirtualHost>
but it goes 400 bad request that server couldn't understand.
now I don't know what to do......... please give me a advices. Thanks!