- Below both are working fine, so choose any 1 option.
- In .htaccess file, add below lines right after "RewriteEngine on"
# Force redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]- In virutal host, default configuration file add below line and restart apache server.
# In /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
....
....
Redirect permanent "/" "https://[YOUR IP ADDRESS OR DOMAIN NAME]/"
...
</VirtualHost>