Use .htaccess to redirect to https

If you need to redirect any request in a site to https you can use mod rewrite in a htaccess file. In this specific case we want to redirect whatever insecure url is used to a secure url. The advantage is that it doesn’t do a thing in the request was already secure. Also if you have multiple headers pointing to that directory, the htaccess file will redirect them preserving the original host header use the code below.

RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}