WordPress – Removing AMP Plugin

I’m actually big fan of this wordpress plugin despite the bugs. The authors of this plugin I can tell have been working hard in fixing existing bugs and there are a lot of them, not an easy task. As a developer myself I know how wild code can get, so I give these guys mad respect and credit.

AMP for WP

Recently I was tasked with removing this plugin for a site. Disabling and removing the plugin was just the first step. The final step was to implement a redirect that would automatically redirect these amp urls to it’s respective non-amp url – leaving this as-is would be bad for SEO. And the client would not be happy to see their google rankings go down. So let’s take care of this.

After playing around with some directives I was able to put together a working solution. Check it out below.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# Redirect AMP to non-AMP
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]

</IfModule>

Were basically saying that if a URL contains the amp string, redirect that URL to the original URL. I found that placing this directive near the top of the .htaccess file worked best.