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?
1 Answer
Reset to default 2The 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
版权声明:本文标题:redirect - Stop forcing certain paths to end with a forward slash 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741309520a2371570.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
.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:25https://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