Apache: Redirecting http to https using a .htaccess file
To redirect http traffic to https in Apache, create a .htaccess file with the following content:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Place the .htaccess file in your website directory and that should be it.
NOTE: The rewrite module in Apache must be enabled for this to work. To check whether it is enabled, open your httpd.conf and make sure the line below is not commented:
LoadModule rewrite_module modules/mod_rewrite.so
If you’re running Apache …