How to Force Redirect from HTTP to HTTPS?
SSL Certificate allows redirecting from HTTP to https. To force a Redirect from HTTP to https with SSL use Apache Handlers /.htaccess file using mod_rewrite.
What is SSL?
SSL means Secure Socket Layer which is helpful in securing the websites from hackers. It provides data encryption between the web hosting server and web browser. Data that are transmitted from the server are encrypted and cannot be viewed by the client without decrypting it. So it helps in preventing the shared information from unauthorized users.
To redirect HTTP to https using Apache mod_rewrite:
Apache mod_rewrite helps to redirect easily from HTTP to https with SSL. So that user who forgets to add https will be automatically redirected to secured websites. First, make sure that SSL certificate is installed to access secured websites. Then Apache is enabled with mod_rewrite.
First open /.htaccess file using # vi httpd.conf
Add the following code to /.htaccess file
RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule^(.*)$ https://%{HTTP_HOST}%{REQUEST_URL} [L,R=301]