Hi! 🙂 Once you have installed the SSL certificates on apache, you can proceed to force HTTPS on your domain. Here are the steps in brief to force https using .htaccess file.
Step 1:
Open the terminal and goto –> the root folder of web site.
In my case it is /home/student/public_html
Step 2:
Command: gedit .htaccess
Then a blank .htaccess file will be opened. You can check the existence of the file by pressing (Ctrl+H).
Step 3:
Put the following lines on the file.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} <your_domain> [NC]
RewriteRule ^(.*)$ https://<your_domain>/$1 [R,L]
Note*: Your_domain can be IP address or the web site address
Example:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} 192.168.56.101 [NC]
RewriteRule ^(.*)$ https://192.168.56.101/$1 [R,L]
Result:
Now you try typing your web site address even with http:// and it will redirected to https:// automatically.
Cheers ! 🙂