How to Fix 404 on AMP Pages After Deactivating the AMP Plugin

Do you want to redirect AMP permalink to the Non-AMP URL? This guide is going to help you.

You might know well, Twitter has also started serving AMP pages. Therefore, using redirection is very important to prevent from 404 hits for old AMP WordPress permalink. After deactivating the plugin, you will receive Error 404 for all AMP permalinks.

To fix this problem, you need to setup a redirect from the AMP to NON-AMP(canonical) URL.

  1. Go to Yoast SEO Plugin > Tools > File Editor
  2. In the .htaccess field add AMP to Non-AMP path redirection rule
  3. and Save changes
# Redirect from AMP to non-AMP path
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteCond %{REQUEST_URI} !^/wp-content/(.*)$ 
RewriteRule ^ %1/ [R=301,L]

Important changelog IST 3:15 PM 5/11/2017
* Excluded wp-content, concerning images which may contains ‘amp’ in the name.

What if you don’t have control to .htaccess?

Alternatively, you can also prevent 404 by doing a redirect from AMP to non-AMP path (canonical) pages using a free plugin called “Redirection“.

redirection
  1. Install a free plugin called “Redirection
  2. Go to WordPress Dashboard > Tools > Redirection
  3. Add a new 301 Redirection
  4. Keep source /(.*)\/amp
  5. Target URL https://www.yourdomain.com/$1

Kindly note: These steps should be implemented after disabling/noindexing AMP properly.

How do I set AMP to Canonical Redirect in case of NGINX?

location ~ /amp/?$ { rewrite ^(.*/)amp/?$ $1 permanent; }

Where I can find .htaccess file? 🤔

In the Apache server, .htaccess file is typically located in public_html directory. Or using Yoast File Editor or via WP File manager plugin can also be helpful.

Which method should I use .htaccess or Redirection?

If you’re using Apache web server then go with .htaccess else plugin way is easy.

My Search Console is still showing 404

Search Console may take some time to refresh data. Wait for few days and check again.

I hope this guides helps in fixing 404 for AMP URLs. If you have any specific query, please feel free to ask. Thanks!

Any question? Please ask at Gulshan Forum.

Comments are closed.