The redirects you are seeing are not related to the plugin. You can see them as well if you remove the amp
slug and add anything to the end of the URL. They have to do with the example.com site.
@rryyaanndd Please share the actual URL for your site. The example.com
site is not WordPress, naturally: https://en.wikipedia.org/wiki/Example.com
The URL here does not really matter. The author just used example.com
for the sake of an example.
I can see this with a few sites running Classic Mode. You can append whatever you want after /amp/
and the URLs still work. Not sure how big of a deal that is though.
Right. That’s just how WordPress rewrite rules work.
For example, adding a feed endpoint can results in URLs that end in /feed/
or /feed/rss2/
. The second slug after feed
is used as the value for the query var, for example feed=rss2
. By obtaining a URL like /amp/XYZ/
this is the same as ?amp=XYZ
. And since we just check for a non-empty value, the plugin treats it all the same: an AMP page is served.
Adding an endpoint creates extra rewrite rules for each of the matching places specified by the provided bitmask. A new query var with the same name as the endpoint will also be created. The string following the endpoint definition supplies the value for this query var (e.g. "/foo/bar/" becomes "?foo=bar").
Thread Starter
Ryan
(@rryyaanndd)
Correct, example.com was just an example.
Non-AMP pages return 404 when adding anything after the post/page url. I don’t see this behaviour from normal WordPress posts/pages.
404 – http://www.example.com/blog/post-title/XYZ
404 – http://www.example.com/blog/post-title/XYZ/XYZ
Also, multiple “levels” (or “directories”) still work for AMP pages.. like:
http://www.example.com/blog/post-title/amp/XYZ/XYZabc/XYZ123/XYZ/12/2/1/1/
returns the same content as /amp/
The problem is this creates an unlimited number of amp pages for the same one post.
Also, people can craft the URL to appear different than the website/author intended.
I don’t have a wordpress site publicly accessible, but any classic mode seems to behave this way. Previously posted sites on this forum have this issue as well:
https://www.porte-blindate.info/spioncini-digitali/spioncino-digitale-con-sensore-di-movimento-brinno/amp/yes/i-love-lamp/
https://www.der-bank-blog.de/fuehrung-digitalisierung-und-andere-herausforderungen-fuer-die-zukunft/strategie/15118/amp/xyz/xyz/123/345383/yes/
https://www.redanalysis.org/2019/01/14/inserting-artificial-intelligence-in-reality-drivers-of-ai/amp/paypal.com/send/
I believe this issue may be a duplicate to what is reported at https://github.com/ampproject/amp-wp/pull/910
Can you confirm?
Thread Starter
Ryan
(@rryyaanndd)
Yes, it looks like the same issue.
Ok, please subscribe to that pull request for further updates.
Correction: Here is what I believe to be a better approach: https://github.com/ampproject/amp-wp/pull/1846