Redirecting website HTTP (port 80) traffic to HTTPS (port 443) is very easy under Apache.
- Open the website’s HTTP VirtualHost file.
- Inside the VirtualHost block, near the very end, add line (with your website’s primary domain name substituted in):
Redirect / https://www.example.com/
- Also make sure the HTTPS VirtualHost file does not have a similar line in it that redirects back to HTTP, or your Browser will go into a loop.
- Save VirtualHost files. Restart Apache.
For this to work correctly, without any Browser warnings, your website will need to have the proper SSL Certificates installed. Most Browsers will not allow you into a website that is using self-signed certificates (nor mismatched “Common Name” / domain name certs).