Few days ago I disabled AMP support on my site.
To disable AMP support, I took the following steps.
- Log in to my WordPress dashboard
- Go to Plugins -> Installed Plugins
- Find “AMP” plugin
- Click “Deactivate” link under the AMP plugin
- Click “Delete” link under the AMP plugin
That is all I had to do, and 24 hours later AMP link to my site was gone from Google Search Results.
The only issue I noticed is that old AMP links were now returning a 404 – Page Not Found message.
For example:
https://www.alexkras.com/my-history-with-web-development-or-javascript-fatigue/amp
would return 404 since there was no longer a /amp
version of the link.
Redirect All 404s to Homepage
To remedy this issue, I’ve downloaded the All 404 Redirect to Homepage
- In WordPress dashboard
- Go to Plugins -> Add New
- In top right corner search for “All 404 Redirect to Homepage”
- Click “Install Now” button for the first result
- Click “Activate” button for the first result
As the name of plugin suggests, it will redirect all 404 to the home page. I already have a list of all post on my homepage rendered, via Clean My Archives plugin, so it was a decent solution in and of itself.
Redirect All AMP links to non AMP version
I wanted to take it one step further, though, so I modified the plugin to re-write AMP links to non amp version.
The steps to do so were as follows:
- In WordPress dashboard
- Go to Plugins -> Editor
- In top right drop down select “All 404 Redirect to Homepage” and click select
- It should open the
all-404-redirect-to-homepage/all-404-redirect-to-homepage.php
file for editing - In it find
if($options['p404_status']=='1' & $options['p404_redirect_to']!=''){
line - Copy paste the following code right bellow it (and indent it one tab extra so it looks readable)
- Click “Update File” link right at the top left corner
if (strpos($link, "/amp") !== false) {
header ('HTTP/1.1 301 Moved Permanently');
header ("Location: " . str_replace('/amp', '', $link));
exit();
}
It should look as the following image:
Finally, test it by navigating to an /amp
version of any page on your site (after you’ve disabled AMP) to confirm that the redirect worked.
I am planning to write a proper WordPress plugin and publish it on Github, if there is interest. Please follow me on Twitter if you would like to hear more or DM me if you’d like to participate.
For now I wanted to share this quick hack as a stop-gap solution, until the proper plugin can be developed.
Going to try this method.
Thanks! the plugin method worked perfectly. I edited the plugin and it is redirecting amp to non amp.
Brilliant, just what I was looking for, I was getting fed up of AMP causing a big issue with bounce rate, plus recently AMP wasn’t rendering, so I was getting 500 errors when the site was getting hits from Twitter on mobile. So thanks for the help, it’s worked a charm.
Thank you for this! Looking to try it out because I noticed all of my blog’s posts on twitter were kept in AMP which didn’t show a lot of the features I had on the site.
Such an excellent example of a fine blog post. Useful instructions, easy to follow and the solution works like a dream. Thank you, thank you, thank you for posting this.
o My God thanks a lot it worked perfectly on my website.
Thanks! the plugin method worked perfectly. I edited the plugin and it is redirecting amp to non amp.
If you are using SEO plugin Yoast just enter this fix in the redirection section of the plugin.
Keep source /(.*)\/amp
Target URL https://www.yourdomain.com/$1
No need for extra plugin.
Hi
Instead of using a plugin, use .htacess:
Redirect from AMP to non-AMP path
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]
Thank you. This method is worked for me. 🙂
Hi there! I have removed AMP from my plugins. My website is quite new so there are no /amp/ links floating online.
I am trying now to post a new link to twitter and it still automatically add /amp/ to the end of my link… Do you know of a way to make it stop?
Thank you for the article – I thought I was the only that did not link AMP.
Hmm, if you have disabled AMP plugin, and it’s still happening. My guess is Twitter cached your site as “AMP enabled”. I would still implement redirect plugin outlined above and it should fix the issue.
Usd this method and let me see if it works.Anyways, great post
Worked like a charm! Thanks for a great guide on how to disable AMP on WordPress.
Thanks Its Work
worked for me thanks alot
amazing waiting for AMP to be Removed From Search Engine
Thank you for helping! Your script save me a lot of time!
thanks !!! help me a lot!
amazing!!
Thanks, that worked perfectly on my site.
Hey Alex, loved the article about why you chose to turn AMP off. I’ve never liked the idea of AMP for many of the same reasons you cite here. I’m heavily into the marketing side of the industry now and see the movement towards AMP as a slight against our industry.
As you said, why not rely on responsive Web practices like you demonstrated and try to minimize JS so our sites work on more browsers and devices and connections world wide?