0

As far as I understand, WordPress prefers a trailing slash at the end of your URL.

However, it applies this rule also to https://example.com/amp, so I get a 301 Redirect to https://example.com/amp/. Unfortunately, Google Search Console now complains of:

Content mismatch between AMP and canonical pages (Critical)

And my "error" is the HTTP 301 redirect for https://example.com/amp but the actual contents for https://example.com/. How can I resolve this? For reference, my .htaccess for the root directory is the standard:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I tried inserting RewriteCond %{REQUEST_URI} !^/amp$, but that didn't work. How should I resolve this?

  • the error that you cite here doesn't sound like it is related to redirects – Mark Kaplun Aug 12 '17 at 4:48
  • 1
    "I tried inserting ..." - the .htaccess code you posted is simply the standard WordPress front controller. If your pages are redirecting to append the slash then this is internal to WP. But also, I'm not sure why a "canonical redirect" would result in such an error? Are you not linking to the canonical (with a slash) /amp/... URL to begin within? – MrWhite Aug 12 '17 at 14:25
  • @MrWhite Ack, you're right - in my https://example.com page I have <link rel="amphtml" href="https://example.com/amp" /> - looking around I see this is an open bug on the plugin, but I think soon to be fixed, so I have nothing to do. This question should probably be deleted since it is about a transient bug. – Ken Y-N Aug 12 '17 at 15:46
  • 1
    Or you could perhaps add an answer with that information as it could help others who are faced with a similar/same problem. – MrWhite Aug 12 '17 at 15:48
2

The problem was not in my redirects, but instead it is a bug/lack of a feature in the existing AMP for WP plugin. The issue is described here and the bug fixes are shown here if you want to be brave and patch the plugin directly. I can vouch that this works for my root directory issue for the current 0.9.58.1 release.

If you don't feel brave, as far as I can gather from the GitHub page, this fix should appear in version 0.9.59, which might be in a couple of weeks or so.

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.