How to Disable AMP on WordPress

Table of Contents

Few days ago I disabled AMP support on my site.

To disable AMP support, I took the following steps.

  1. Log in to my WordPress dashboard
  2. Go to Plugins -> Installed Plugins
  3. Find “AMP” plugin
  4. Click “Deactivate” link under the AMP plugin
  5. 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://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

  1. In WordPress dashboard
  2. Go to Plugins -> Add New
  3. In top right corner search for “All 404 Redirect to Homepage”
  4. Click “Install Now” button for the first result
  5. 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.

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:

  1. In WordPress dashboard
  2. Go to Plugins -> Editor
  3. In top right drop down select “All 404 Redirect to Homepage” and click select
  4. It should open the all-404-redirect-to-homepage/all-404-redirect-to-homepage.php file for editing
  5. In it find if($options['p404_status']=='1' & $options['p404_redirect_to']!=''){ line
  6. Copy paste the following code right bellow it (and indent it one tab extra so it looks readable)
  7. 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();
}
Code language: PHP (php)

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.

25 thoughts on “How to Disable AMP on WordPress”

  1. Thanks for sharing. Your steps work like a charm. Been getting error notifications of AMP from search console tool. Hopefully this will fix it. Thank you

  2. 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.

  3. 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.

  4. 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.

  5. 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]

  6. 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.

  7. 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?

Comments are closed.