• Resolved Carlo

    (@dodo67)


    Hi, I saw the the topic opened by Paul Bearne and titled “redirection loop with WPML”. It’s marked as resolved, but I still have that same problem.

    My site is configured to work with HTTPS, and in wp_options table both ‘siteurl’ and ‘home’ options ad set to ‘https://www.mydomain.com’.

    My site is multilanguage, using WPML plugin. Three languages are configured: https://www.mydomain.com/it/, https://www.mydomain.com/en/, https://www.mydomain.com/es/ and all is fine.

    But when I activate your plugin, the browser start redirecting from https://www.mydomain.com/it/ to https://www.mydomain.com/it//it/ and then https://www.mydomain.com/it//it//it/ and so on. An infinite redirects chain.

    By debugging your code I found that probably the problem is in lh-hsts.php on line 71:

    if($this->current_domain == "https://". $this->domain || $this->current_domain == "https://". $this->domain){

    because just before the first redirect above, the values of ‘current_domain’ and ‘domain’ are:

    $this->current_domain: https://www.mydomain.com/it/
    $this->domain: ‘www.mydomain.com’

    so the two comparisons cannot be true.

    Probably the WPML plugin change somehow the ‘home’ value returned by get_home_url() (line 47 of your code) so that the ‘if’ on line 71 always return false, so the ‘else’ branch is executed.
    Here the redirect is built with $this->current_domain together with $this->uri, and uri is ‘/it/’ so the redirect url is: https://www.mydomain.com/it//it/

    The same happens when the browser follows this redirect: $this->current_domain is the same as before, the ‘if’ is false, and a new redirect is built, but this time the $this->uri value is ‘/it//it/’, so the final redirect url is: https://www.mydomain.com/it//it//it/
    And so on.

    How to solve the problem?

    • This topic was modified 3 years, 8 months ago by Carlo.
    • This topic was modified 3 years, 8 months ago by Carlo.
    • This topic was modified 3 years, 8 months ago by Carlo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author shawfactor

    (@shawfactor)

    The problem really lies with WPMl doing something funky with get_home_url(), so you should probably bring it to their attention however.

    I can think of a few ways if you don′t want to go down that route.

    The easiest si probably to add a filter to $this->current_domain = get_home_url()

    so that you could reverse the wpml behaviour yourself. This would solve your issue without me creating other problems elsewhere.

    Plugin Author shawfactor

    (@shawfactor)

    I am resolving this for good order but I will still monitor the thread and reopen it if necessary.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirection loop with WPML still present’ is closed to new replies.