A simple and very straight forward way to force redirect http requests to https without amending your website code in environments where the server hosting your website is behind a load balancer (such as for most shared hosting/cloud platforms) is by using this piece of code in your .htaccess file:

RewriteEngine On
RewriteCond %{ENV:SSL} !1
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]