I have the following htaccess code:
RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{RE
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
Notes: Make sure you have done the following steps
- sudo a2enmod rewrite
- sudo service apache2 restart
- Add Following in your vhost file, located at /etc/apache2/sites-available/000-default.conf
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
Now your .htaccess will work and your site will redirect to http:// to https://www