Redirect from AMP URLs to Real URLs

2019-07-20 07:55发布

I want to convert old links amp links to basic topics in wordpress Via the .htaccess file I tried this code but it did not work

#Redirect old AMP URLs
RewriteRule (.*)/AMP$ $1 [NC,R=301,L]

#Redirect old AMP URLs
RewriteRule (.*)/amp/$ $1 [NC,R=301,L]

I want Redirect from

to

2条回答
Animai°情兽
2楼-- · 2019-07-20 08:33

In WordPress, for redirecting your all AMP URLs to NON-AMP (Canonical) version, you may use below rule -

# Redirect from AMP to non-AMP path
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteCond %{REQUEST_URI} !^/wp-content/(.*)$ 
RewriteRule ^ %1/ [R=301,L]

Source: https://www.gulshankumar.net/fix-404-on-amp/ Disclaimer: I am author.

查看更多
Ridiculous、
3楼-- · 2019-07-20 08:36

Use this

RewriteRule ^(.*)/amp$ $1 [R=301,L]
查看更多
登录 后发表回答