Debian 11
config file: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
ServerName zabbix.example.ru
</VirtualHost>
<VirtualHost *:443>
ServerName zabbix.example.ru
DocumentRoot "/usr/share/zabbix/"
</VirtualHost>
If I open in brouser zabbix.example.ru it will be open by https. But if I open manualy http://zabbix.example.ru it doesn't redirect to https
The same setting (as I understand) perfectly forks for me on FreeBSD, but it looks like on Debian I should make something other
/usr/sbin/apachectl -S
VirtualHost configuration:
*:80 zabbix.lasil.ru (/etc/apache2/sites-enabled/000-default.conf:1)
*:443 zabbix.lasil.ru (/etc/apache2/sites-enabled/000-default.conf:9)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
UPD: I was a little wrong about problem. Not only there is no redirect, but such an error is also issued
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Apache/2.4.54 (Debian) Server at zabbix.example.ru Port 80