admin管理员组

文章数量:1287561

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

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

Content mismatch between AMP and canonical pages (Critical)

And my "error" is the HTTP 301 redirect for but the actual contents for /. 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?

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/amp, so I get a 301 Redirect to https://example/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/amp but the actual contents for https://example/. 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?

Share Improve this question asked Aug 12, 2017 at 4:30 Ken Y-NKen Y-N 1771 gold badge1 silver badge11 bronze badges 4
  • the error that you cite here doesn't sound like it is related to redirects – Mark Kaplun Commented Aug 12, 2017 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 Commented Aug 12, 2017 at 14:25
  • @MrWhite Ack, you're right - in my https://example page I have <link rel="amphtml" href="https://example/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 Commented Aug 12, 2017 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 Commented Aug 12, 2017 at 15:48
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: redirectStop forcing certain paths to end with a forward slash