I have a website and I need the following redirections :
- www.example.com > example.com
- http requests redirected to https
I wrote the following rules :
#Redirect http://example.com to https://example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ https://example.com$1 [R=permanent,L]
#Redirect www to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^(.*)$ https://example.com$1 [R=permanent,L]
The rules are not working and I’m getting the error : domain.com redirected you too many times.
Does anyone know how to solve that please ?
Thanks
2
Answers
Thanks to the help of Anubhava, I could get a working solution :
Your first rule seems to be the culprit which is not checking for
http / https
and redirecting tohttps
.You may use: