Support » Plugin: WP-Matomo (WP-Piwik) » Failure to connect on 302 Found

  • Resolved Thomas

    (@thohenberger)


    Hello André,
    I have trouble connecting WP-Matomo to a Matomo server (updated from Piwik).
    One blog connects with HTTP return code 200. Another blog returns 302 Found.
    I am not an expert, but this is a secondary domain, which is an alias to the original URL. Both domain names are set in the Matomo web site definition.
    Doesn’t 302 mean, that the webserver had found a resource which is fitting?
    WP-Matomo is refusing to use the connection. Could this be treated as an okay condition instead?
    Can you give me some hint on how to avoid the 302 failure?
    I am running: WP-Matomo 1.0.22, Matomo 3.11.0, WordPress 5.2.4.
    Thank you very much in advance!
    Best regards
    Thomas

    • This topic was modified 4 months ago by Thomas. Reason: added version numbers
    • This topic was modified 4 months ago by Thomas. Reason: added version numbers
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author braekling

    (@braekling)

    Did the URL change? Are you doing a redirect?

    You should always try to connect to Matomo directly, without any redirects in between.

    Thomas

    (@thohenberger)

    Hi,

    I guess my post was not clear enough: I am moving different blogs and Piwik from one provider to another. Domains move slowly. Therfore I am in a situation, where the Blog is still the old server, but the upgraded Piwik, now Matomo resides on a new server. Thus I redirect the old blog to the Matomo installation.

    Both, Matomo and WP-Matomo are the latest versions. The only other difference is, that the old blog is on another server and the Matomo instance has a different address now. I do not see why there is a HTTP return code of 302.

    Matomo is configured to serve both URLs, the old blog and the new blog, both running under different domains right now, until the old domain is available with the new hoster.

    I am afraid, that there is a problem with the new Matomo installation. I have added the intermediate domain as an alias, but this should not matter or result in a 302.

    I am not doing a redirect. This seems to happen somehow internally.

    If I switch back to the old Piwik installation, the blog connects through WP-Matomo. I also tried to renew the Auth-Token, but it did not change.

    I could wait for all domains be available at the new provider, but I am afraid to have the same issue later on.

    Any idea is very welcome.

    My simple hope was, that a 302 might be treated as a 200 in WP-Matomo, because it says “found”, but this might be way too simple…

    May thanks for your great work!

    Best regards
    Thomas

    P.S.: Just an addon remark which might be worth mentioning:

    I just had recognized, that the WP-Matomo site-browser shows the Blog address with no Blog-ID (“-“) and Site-ID “Seite noch nicht erstellt.” (Site not yet created.)

    This shows, that there is a connection, but the blog is not recognized. Does this help?

    • This reply was modified 4 months ago by Thomas. Reason: P.S.: info on site-browser result
    Plugin Author braekling

    (@braekling)

    The response code 302 means a redirect, see the definition: https://en.wikipedia.org/wiki/HTTP_302
    In WP-Matomo you always have to give the final URL, i.e., the URL response is redirecting to.

    If you don’t know where this redirect leads to, try a tool like http://www.rexswain.com/httpview.html and have a look at the location value.

    The redirect is defined in your web server’s configuration. It is not affected by your Matomo configuration like aliases.

    • This reply was modified 4 months ago by braekling.
    • This reply was modified 4 months ago by braekling.
    Thomas

    (@thohenberger)

    Great help! Great Tools! Thank you! Problem solved!

    The httpview tool revealed that the reason for the redirect and the 302 result: It was a redirection from http to https. Nothing else.

    cPanel showed no force-https-redirects, but I remembered, that there had been an advice to set https redirects in Matomo. This is set by the configuration variable force_ssl in the [General] section of config.ini.php.

    I had reset the variable to 0 and WP-Matomo just works fine!

    Nevertheless: Wouldn’t it be permissible to allow 302 return codes in WP-Matomo and thus enable the force_ssl feature?

    I don’t know the programming details, but I would volunteer to test, if you consider implementing this.

    Until now, I can only recommend to leave force_ssl at 0 with WP-Matomo.

    Thank you again!
    Best regards
    Thomas

    Thomas

    (@thohenberger)

    Please allow me to follow-up myself on the last post.

    Of course it would be more simple to directly use the https-URL instead of programming code for the 302. Therefore I have tried using the https-URL directly in order to hide the auth token.

    Despite problems with using https with WP-Matomo, which occurred earlier in combination with the force_ssl setting, everything works smoothly now.

    Therefore again my learning and advice: Avoid ‘force_ssl’ with WP-Matomo.

    All problems solved!
    Thank you again.
    Thomas

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.