<Files /var/www/html/>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}:443%{REQUEST_URI}
I only have one domain on this server. The one issue I have is if the IP address is typed in directly it does not redirect too https://the_ip. Anyway to make that work?
Where in httpd.conf did you place it? Inside a section? Or just “bare” without any <foo bar> and </foo> around it?
Anyway, do note that redirecting to an IP address with HTTPS will not work in case of a Let’s Encrypt certificate, as Let’s Encrypt doesn’t issue certificates with an IP address as a SAN (or CN for that matter). Therefore, redirecting to an IP address with HTTPS with a LE cert will give the client an error (CN mismatch).