visit
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 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 pages in bulk to their non-AMP counterparts. I should note that there are various ways to do this outlined in : Nginx, Apache, and Cloudflare. However, I was taught this fix is way quicker and doesn’t require editing files.
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.
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/
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/
.
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.
This time, in the Source URL, you need to add this expression ^/(.*?)/amp/$
In the Target URL input, this expression /$1/