How to Redirect Your AMP URLs on WordPress in Bulk w/Redirection Plugin

Written by Limarc | Published 2022/11/22
Tech Story Tags: wordpress | wp | amp | google-amp | wordpress-plugin | wordpress-website | wordpress-tutorial | wordpress-development

TLDRIn this article I’ll show you a quick 1-minute fix to redirect ALL your AMP pages in bulk to their non-AMP counterparts. I should note that there are various ways to do this outlined in this article: Nginx, Apache, Cloudflare. However, this fix I was taught is way quicker and doesn’t require editing any files. via the TL;DR App

So I don’t normally write web dev stuff on HackerNoon because I’m not a dev at all and don’t want to embarrass myself. However, I was faced with a big issue on my anime and Japan blog recently that I’m sure others have faced as well; I disabled AMP (for various reasons), so my AMP pages were 404ing, and I needed to redirect them to their non-AMP counterparts.

In this article, I’ll show you a quick 1-minute fix to redirect ALL your AMP pages in bulk to their non-AMP counterparts. I should note that there are various ways to do this outlined in this article: Nginx, Apache, and Cloudflare. However, I was taught this fix is way quicker and doesn’t require editing files.

Table of Contents:

  1. Why my AMP pages were 404ing

  2. How to redirect AMP pages one by one

    1. Plugin
  3. How to redirect AMP pages in bulk

    1. Expressions

Why Are My AMP Pages 404ing?

I think the AMP plugin developer needs to fix this.

For various reasons, I decided to disable AMP on my WordPress site. The AMP plugin auto-generates all your pages into their AMP forms, and Google usually prefers those pages for mobile and indexes the AMP URL.

The issue with that is when you disable the AMP plugin, all the AMP URLs will still be indexed on Google, and when people click them, they will be served a 404 error page or an OOPS that can’t be found page.

AMP should auto-redirect all AMP URLs to their regular URL counterparts if the user disables the plugin.

But alas, the plugin doesn’t do that, and we’re left with dozens or hundreds of URLs that no longer exist, and we have to redirect them.

How to redirect AMP pages one by one

So the plugin you’ll need to download (if you don’t already have it) is Redirection by John Godley. And believe me, it is a…godly plugin 😉

The Redirection Plugin

In this section, I’ll explain how to redirect single AMP URLs one by one if, for whatever reason, you don’t want to redirect them all.

Once you’ve installed the plugin, you should be able to access it on your WP dashboard under tools → redirection:

It should look like this:

In the Source URL, you put the AMP url slug (no need to add your domain) : /my-post-2/amp/

And the closed bracket / at the end is necessary.

In the Target URL you need to put your redirect which would be the exact same minus /amp/ and thus should just be something like /my-post-2/ .

Click “add redirect” and you should be done! Be sure to check the AMP url to see if its redirecting properly.

How to redirect AMP pages in bulk

If you want to redirect ALL your AMP pages in one go, we can use the same plugin as above and it’ll take literally 1 minute or so.

Step 1. Navigate to the Redirection plugin

Step 2. Set Regex option

Step 3. Input the proper URL expressions

Step 4. Add redirect

Navigate to the Redirection plugin using the same steps as in the above section.

This time, click on URL options/Regex.

Select Regex.

This time, in the Source URL, you need to add this expression ^/(.*?)/amp/$

In the Target URL input, this expression /$1/

Click “add redirect”, and you should be done!

Check to see if this worked by adding /amp/ to any of your articles and seeing if it auto-redirects. You can do the same on your mobile phone.

If this doesn’t work, your WP site might be using a different URL structure. You can see a more in-depth list of expressions to use here.

Final Thoughts

That’s it! I hope this worked for you because it was super frustrating for me, and I didn’t feel like learning where my htc access file was and then learning how to edit it.

Luckily, this plugin makes it easy and doesn’t require any in-depth development knowledge.

If that doesn’t work for you, or you know a better way to do this, please comment below! I’m not an expert, but I’d be happy to help you if I can.


Written by Limarc | Hacker Noon's VP of Editorial by day, VR Gamer and Anime Binger by night.
Published by HackerNoon on 2022/11/22