Question: How to automatically redirect HTTP request to HTTPS in Apache Web Server?
Using HC Panel interface when you enable SSL certificate on a website it will create only HTTPS (:443) entries in the apache web server. Those who do not want to map HTTP (:80) virtual host entry in apache then you can simply redirect the all non-secure web requests toward secure HTTPS by following below instructions:
- Access the Linux Server and go to path "/etc/httpd/conf.d"
- Create a file with name redirect.conf
- Open the file in editor vi redirect.conf and make an entry for a website that you want to redirect automatically from HTTP to HTTPS
Redirect permanent / https://linuxsite1.com/
Redirect permanent / https://mysite2.com/
Save the file and exit from editor
- Now open httpd.conf and include the redirect.conf file in it
save and exit
- Restart httpd service