Posted on: October 21, 2022
Written by: Mick Sherry
If you’ve removed Accelarated Mobile Pages (AMP) from your website or blog, you may need to redirect all the old /amp/ URLs back to the original, non-AMP URL.
To do this automatically, add this line to the .htacces file on your apache server:
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]
This will blanket redirect all AMP URLs back to the original non-AMP URL.
Note: Only advanced users should modify their .htaccess file. If you are unsure, send a support ticket to your hosting company and ask them to implement this for you.
If your website is running on WordPress, here is a safer and more user-friendly way you can redirect all /amp/ URLs to their original URL across your site.
AMP Redirect in a .htaccess File – Example
Example implementation in a WordPres .htacces file below:
This snippet will work on any CMS (including WordPress) as long as your webserver is running on apache.
Why would you need to redirect AMP pages?
This is a quick/useful way to redirect your old AMP URLs and avoid 404 errors or crawl errors in Google Search Console.
You will need to do this if you’ve previously used AMP on your website you’ve recently decided to disable or remove it.
I have added the snippet
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]
to my ,htaccess file ahead of the # END WordPress line.
It doesn’t seem to be working. For example, the URL https://agingslowdown.com/20-super-foods-to-boost-your-immune-system?amp=1 brings up the AMP page rather than redirecting to the non-AMP page.
Hey Phil, sorry to hear it’s not working for you.
The issue is likely the positioning of the snippet, try moving it so it comes before the # START WORDPRESS # line and then let me know if it works for you.
Cheers
Michael