Apache: Redirect HTTP to HTTPS

Are you using Apache and want to redirect all HTTP requests to HTTPS? Look no further. Open an existing .htaccess file or create an .htaccess file in the root directory of the public folder for the domain you'd like to make the change to and enter the code below:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

You can read more about Redirecting HTTP to HTTPS on the Apache website located at https://wiki.apache.org/httpd/RewriteHTTPToHTTPS