I am trying to redirect users to https://example.com when they enter http://example.com in the browser. I am using .htaceess to acheive the redirection. Problem is after adding below .htaccess to my site, browser(chrome) shows This webpage has a redirect loop . This is my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Please suggest me the solution
User below code :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}