1

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

DNS Zone Records DNS Zone Record

What might be the cause?

7
  • 1
    I was able to solve the problem. It was a magento setting. More infos
    – Black
    Dec 12, 2018 at 11:28
  • Aside: Any reason why you are not redirecting to HTTPS with your .htaccess redirect?
    – MrWhite
    Dec 12, 2018 at 11:30
  • @MrWhite, no, It is just dev .htaccess. I think I could just use RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] instead of RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    – Black
    Dec 12, 2018 at 11:32
  • 1
    Write a proper answer.
    – Sven
    Dec 12, 2018 at 11:35
  • Yes, if your site is HTTPS then you should simply redirect to 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?)
    – MrWhite
    Dec 12, 2018 at 11:36

1 Answer 1

3

I was able to solve the problem. It was a magento setting.

There is a setting in system->configuration->Web->Url Options->Auto-redirect to Base URL. Set that to 'No'.

3
  • I can accept this answer in 2 days.
    – Black
    Dec 12, 2018 at 15:23
  • 1
    If that solved the problem, then the base URL is almost certainly wrong. Check it and fix it. Dec 12, 2018 at 17:27
  • Thanks for the hint @MichaelHampton. You are right, I also had to change the Base URL in the backend (for secure and unsecure) from https://mycompany.de/ to https://www.mycompany.de/
    – Black
    Dec 13, 2018 at 8:28

Not the answer you're looking for? Browse other questions tagged .