I am forcing my webserver to rewrite a none www URL to www, e.g. https://example.com
to https://www.example.com
, via .htaccess
.
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But my site does not load with www and prints ERR_TOO_MANY_REDIRECTS.
If I enter a URL like https://www.example.com/some-uri
then I get redirected to https://example.com
What might be the cause?
.htaccess
redirect?RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
instead ofRewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
https://...
. The directive as it stands would keep the user on HTTP - if that was requested. Unless you have something before that redirects to HTTPS? (And/or possibly result in a 2nd redirect to HTTPS later?)