Hello @griddi,
I’ll try to explain how AMP works, and why we need to include or remove the “www.” from the original URL.
In the AMP pages you cannot load third party scripts, only some scripts supported by the AMP Project, so, in this case case you should load this pages into an <amp-iframe>
tag.
AMP uses a sandbox for loading the page into the iframe, but you need to access the original session and cookies variables for multiple reasons (To verify the captcha, use the datasource fields, etc.), and it is here where start the trick.
AMP doesn’t allow to load into the <amp-iframe>
tag, pages hosted in the same domain if you want sharing the cookies and sessions, for security reasons (into the tag is required to use the sandbox option: amp-same-origin, additional information in the following link: https://github.com/ampproject/amphtml/blob/master/spec/amp-iframe-origin-policy.md).
Now, for the browser these URLs are in different domains:
https://your-website-domain.com
and
https://www.your-website-domain.com
So, if the user visits the URL https://your-website-domain.com, the plugin tries to load into the <amp-iframe>
tag the URL https://www.your-website-domain.com to satisfy the “amp-same-origin” restriction, and then, internally redirect the webpage to the original URL https://your-website-domain.com. The same occurs in the other direction, if the user visits the URL https://www.your-website-domain.com, it tries to load into the <amp-iframe>
tag the URL https://your-website-domain.com to satisfy the “amp-same-origin” rules, and then, internally redirect the user to the webpage: https://www.your-website-domain.com
I know the explanation can be confuse.
My recommendation would be configure your website for accepting both URLs:
https://your-website-domain.com
and
https://www.your-website-domain.com
Best regards.