1

On this multi-language site (NL, FR, EN) we're using the saml plugin to single sign on users into the craft site. That part is working fine. Every user has a preferred lanuage returned into a user custom field userLanguage. What I'm trying to do is simply redirect the French language users to https://mysite.com/fr and the English language users to https://mysite.com/en In my index template I have the following

{% requireLogin %}

{% if currentUser %}
    {% switch currentUser.userLanguage %}

      {% case "NL" %}
        {% redirect 'https://mysite.com'  %}
      {% case "FR" %}
        {% redirect 'https://mysite.com/fr'  %}
      {% case "EN" %}
        {% redirect 'https://mysite.com/en'  %}    
      {% default %}
         {% redirect 'https://mysite.com'  %} 

    {% endswitch %}
{% endif %}
{# rest of homepage template here #}

On visiting https://mysite.com/ I'm redirected to the sso page and after login back to https://mysite.com/ and there I get a "too many redirects" error, in firefox it's "The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete." What am I missing here?

  • 2
    Erwin, can't you check if a redirect is (still) needed? eg if userLanguage == 'NL' && URL == 'mysite.com' then no need to redirect? – Dave Driesmans May 2 at 21:16
  • Maybe it's because I'm redirecting to the same template. mysite.com/fr calls that index template again so it just keeps looping. Hmmm – erwinheiser May 2 at 21:51
1

The answer here was to redirect to another url using a different template rather than hitting the index template again, which was what was causing the loop.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.