Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
In Apache HTTP and Nginx Last updated: October 29, 2022
Share on:
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

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?


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 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$1 permanent;

Replace 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 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.


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.*/amp/
  • Settings as Forwarding URL with 301 and destination URL as below.$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.


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.

  • Abhishek Nair
Thanks to our Sponsors
More great readings on Apache HTTP
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • is an all-in-one work OS to help you manage projects, tasks, work, sales, CRM, operations, workflows, and more.
    Try Monday
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder