Have you disabled AMP on your site and got an error from Google Search Console about “Referenced AMP URL is not an AMP”?

Accelerated Mobile Pages or commonly known as AMP is an open-source web component framework originally created by Google which you could use to easily create user-first websites, stories, emails, and ads.

Fundamentally, it’s a stripped-down version of an HTML page designed to be super lightweight and for fast loading. This platform is designed for speed and readability along with heavy caching for mobile devices. Though as part of a recent announcement by Google, they’re removing the AMP requirement from Top Storie’s eligibility.

In case you plan to opt-out of AMP you’ve to disable the AMP plugin (if using WordPress). But the problem is search engines like Google will still be pointing to your old page with /amp at the end and will land your visitors to 404 - Page Not Found error.

or, you will get an error like.

So, what’s the solution after deactivating AMP to avoid such errors?

Easy!

You need to properly redirect such pages after disabling AMP to avoid this scenario.

If you’re looking for redirecting the AMP page to a non-AMP one, you’re at the right place as we’ll be discussing steps that you can take to do that in popular web servers and services.

So let’s get started.

Nginx

Nginx configuration is stored in nginx.conf.

The file should be available in /etc/nginx or /etc/nginx/conf.d on Linux servers (for an open-source version of NGINX, the location may differ like /usr/local/nginx/conf or /usr/local/etc/nginx).

Edit the nginx.conf file where your site’s/domain’s configuration is stored where you need to enable AMP to non-AMP redirection and add below rewrite line in the server { block:

rewrite ^/(.*)\/amp http://example.com/$1 permanent;

Replace example.com with your own domain and save the file. Restart nginx server to make the redirection change effective.

$ sudo systemctl restart nginx

Now you can verify if redirection is working from your browser.

Apache

Apache used .htaccess directives. You can edit the .htaccess file in the root of your domain and add the following lines for AMP to the non-AMP redirection:

RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]

Save the changes to .htaccess file and verify redirection from your browser.

The above code you can also use on a shared hosting platform for WordPress or other CMS. If you are unsure about .htaccess modification, you can check with your hosting provider.

Cloudflare

Much easier, if you are using Cloudflare. You can take advantage of Rules, which you find on the top icons bar after login.

  • You can have a matching URL as below.
https://example.com/*/amp/
  • Settings as Forwarding URL with 301 and destination URL as below.
https://geekflare.com/$1
  • Click on Save and Deploy

This is what was done for Geekflare.

Wait for few seconds and then try to access the AMP URL and you will notice it is getting redirected to a non-AMP page.

Summary

We’ve covered a brief introduction about AMP and why it has been in use. AMP to non-AMP redirection is an essential step to be done post disabling AMP to avoid losing out on your site visitors due to 404 errors. This can be easily achieved using permanent redirection as mentioned above.