#/etc/apache2/apache2.conf
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
sudo a2enmod rewrite
sudo service apache2 restart
#.htaccess in directories that needs forward https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Note: this may be a problem if you’re behind https reverse proxy that forward to http