Πώς να διορθώσετε το 404 στις σελίδες AMP μετά την απενεργοποίηση του AMP Plugin

Σημείωση: Θα πρέπει πρώτα να noindex /amp/ pages.

Θέλετε να ανακατευθύνετε το AMP permalink στη διεύθυνση URL μη-AMP; Αυτός ο οδηγός θα σας βοηθήσει.

Ίσως γνωρίζετε καλά, ότι το Twitter έχει επίσης αρχίσει να εξυπηρετεί σελίδες AMP. Ως εκ τούτου, η χρήση ανακατεύθυνσης είναι πολύ σημαντική για την αποφυγή χτυπημάτων 404 για παλιές AMP WordPress permalink. Μετά την απενεργοποίηση του πρόσθετου, θα λαμβάνετε Error 404 για όλους τους AMP permalinks.

Για να διορθώσετε αυτό το πρόβλημα, πρέπει να ρυθμίσετε μια ανακατεύθυνση από το AMP σε μη-AMP(κανονικό) URL.

  1. Μεταβείτε στο Yoast SEO Plugin > Εργαλεία > File Editor
  2. Στο πεδίο .htaccess προσθέστε τον κανόνα ανακατεύθυνσης διαδρομής AMP προς Non-AMP
    yoast tools file editor htaccess
  3. και Αποθήκευση αλλαγών
# Redirect from AMP to non-AMP path
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteCond %{REQUEST_URI} !^/wp-content/(.*)$ 
RewriteRule ^ %1/ [R=301,L]

Σημαντικό changelog IST 3:15 PM 5/11/2017
* Εξαιρείται το wp-content, που αφορά εικόνες οι οποίες μπορεί να περιέχουν ‘amp’ στο όνομα.

Τι γίνεται αν δεν έχετε τον έλεγχο της .htaccess;

Εναλλακτικά, μπορείτε επίσης να αποτρέψετε το 404 κάνοντας ανακατεύθυνση από AMP σε σελίδες χωρίς μονοπάτι AMP (κανονικές) χρησιμοποιώντας ένα δωρεάν πρόσθετο που ονομάζεται “Redirection“.

redirection
  1. Εγκαταστήστε ένα δωρεάν πρόσθετο που ονομάζεται “Redirection
  2. Μεταβείτε στο ταμπλό του WordPress > Εργαλεία> Redirection
  3. Προσθέστε ένα νέο 301 Redirection
  4. Κρατήστε την πηγή /(.*)\/amp
  5. URL στόχου https://www.yourdomain.com/$1

Παρακαλώ σημειώστε: Αυτά τα βήματα θα πρέπει να εφαρμοστούν μετά την απενεργοποίηση/μη ευρετηρίαση του AMP σωστά.

Πώς μπορώ να ορίσω το AMP σε Canonical Redirect στην περίπτωση του NGINX;

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

Πού μπορώ να βρω το αρχείο .htaccess; 🤔

Στον διακομιστή Apache, το αρχείο .htaccess βρίσκεται συνήθως στον κατάλογο public_html. Ή η χρήση του Yoast File Editor ή μέσω του πρόσθετου WP File manager μπορεί επίσης να είναι χρήσιμη.

Ποια μέθοδο πρέπει να χρησιμοποιήσω .htaccess ή ανακατεύθυνση;

Εάν χρησιμοποιείτε διακομιστή ιστού Apache, τότε χρησιμοποιήστε το .htaccess, αλλιώς ο τρόπος με το πρόσθετο είναι εύκολος.

Το Search Console μου εξακολουθεί να δείχνει 404

Η Search Console μπορεί να χρειαστεί λίγο χρόνο για να ανανεώσει τα δεδομένα. Περιμένετε μερικές ημέρες και ελέγξτε ξανά.

Ελπίζω αυτοί οι οδηγοί να βοηθήσουν στον καθορισμό του 404 για τις διευθύνσεις URL AMP. Αν έχετε κάποιο συγκεκριμένο ερώτημα, μη διστάσετε να ρωτήσετε. Ευχαριστώ!

Σχολιάστε

51 σκέψεις στο “Πώς να διορθώσετε το 404 στις σελίδες AMP μετά την απενεργοποίηση του AMP Plugin”

  1. Hello 🙏 bhai rank Math plugin ki htaccess file me kya same to same ye hi code paste karna hai aur save changes par click karna hai sirf yeh hi ek step karna ke baad kya sabhi amp pages non amp me redirect ho jayege kyu ki bhai mujhe inn files ki knowledge nah ke brabar hai.

    Question (2) bhai htaccess file ke process me ya redirection plugin ke process dono me Amp disable is process ko karne k bad karna hai ya pehle karne hai.

    Please Reply 🙏

    Απάντηση
  2. Sir 🙏

    1. ek sawal hai sir real time find replace ka plugin kya sare process k baad deactivate kar sakte hai.
    2. Redirection wala process kya 5 -7 din baad karna hai jab sare pages de index ho jye. Ya real time, SEO aur redirect
    Ke 3 step ek sath karne hai.

    Please please reply 😭

    Απάντηση
    • 1. Sabse pehle aapko AMP pages ko noindex karna hai jiske liye maine pichle article mein do method bataya hai. Jismein ki Real Time Find and Replace method (as old method) jikra kiya hai. Ek baar AMP noindex ho jaaye fir aap iss Real Time Find and Replace plugin aur apne AMP plugin dono ko hata sakte hain. I repeat jab tak noindex AMP pages na ho tab tak mat hataana. Koi confusion ho to aap fir se sawaal puch sakte hain.

      2. Jab aap pehle step noindex wala complete kar lete hain (approximately in a week), tab jaa kar aapko redirect man ho to set kar lena. Ye jaruri nahin hai but optional agar aap AMP related permalink pe 404 nahin chaahte ho to. So agar Redirect kar lete hain to koi harz nahin hai, in fact behtar hi hoga.

      Agar koi aur questions ho to please contact me.

      Απάντηση
  3. Hello

    Apke batai hui method pe Mein AMP ko delete kiya or uske baad meri Google Search Console account mein or ek error ayya “Reference Amp url is not an Amp” (https:/eample.com/url/to/amp/document.html) ye error arrahihe Gulshan bhai please bataye eshe kaise solve karun.

    Google mein aphi ese mile jisne AMP remove karneka solution essay method se bataya
    Thank you

    Απάντηση
  4. Dear Gulshan, I read your post and tried to redirect my amp urls to my normal url with your information but it doesn’t work

    I have an AMP URL that looks like this: https://www.mydomain/mypost?amp and for that the regex rule: /(.*)\/amp –> https://www.yourdomain.com/$1 doesn’t work 🙁 I also have tried redirect ?amp pages –> source: ^/(.*?)/\?amp=.* –> Target: /$1/ but here the redirection tool tells me that $ for target is wrong. What should I do?

    Thanks for your help.
    Greetings Kathrin

    Απάντηση
  5. Hai Gulshan I need your suggestion.
    Now my amp posts are not showing up in google.com when checked using this format with my blog /*/amp/ , but in google search console it shows I valid post.

    Can I deactivate the ampforwp plugin and delete it.

    As far as for setting up redirect to avoid 404 errors I can add this code to my rank math plugin .htacess editor right.

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

    But I don’t know whether my server is Nginx or not , I am using sitegrounds managed wordpress gogeek hosting plan. So please help me out now I am seeing lots of 404 redirections in wp admin. Thank You for your time.

    Απάντηση
  6. Hi Bro,
    Actually, I have done everything with your method, within some time error gone from the AdSense. Yesterday I disabled Find and Replace plugin.
    Today, when I open my adsense, account its showing. I tried to open my home page like http://www.jiofiber.in/amp ist showing.
    But if i open my post with amp version, then my all post are opening. What is the issue can you tell me, please.

    Απάντηση
  7. Hey Gulshan,

    How are you? It’s been a long time.

    I have a quick question. I am using AMP on my website. In that case, should I optimize my default mobile pages also for speed? Will there be any impact?

    Απάντηση
  8. Hi, gulshan

    I wish, I got your good piece of article before. But unfortunately, I deactivated the amp for wp plugin without disabling/noindexing AMP properly. Now what i can do about the amp pages that shows 404. Should I do redirection or google will take them out after some time.

    Thanks.

    Απάντηση
    • If your AMP pages are still present in Google SERPS, then install AMP for WP first and noindex it properly. Then, after few weeks when all AMP pages goes from SERPs, then set redirect.

      Απάντηση
  9. Hey, gulshan thanks for this informative article. Iam having problem with 404 after disabling amp plugin. I have Followed each and every steps carefully but still having lots of 404 errors on webmaster. Plz help

    Απάντηση
  10. Hi,

    Your code is working fine for posts AMP URLs but not for home page. When I am going to https://example.com/amp, it’s redirecting to https://example.com/amp/

    However, if post AMP URL is https://example.com/post-name/amp then it’s properly redirecting to https://example.com/post-name.

    How do I fix the home page redirect issue?

    Απάντηση
  11. thank you very much for such a wonderfull information, sir
    this is 100% working solution

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

    how many days this code need to be place there
    as i am not using AMP further

    Απάντηση
  12. Hi Gulshan!

    I read your post but I got a little stuck where you show the .htaccess field because mine looks different than yours, mine starts as follows:

    # Use PHP56 Single php.ini as default
    AddHandler application/x-httpd-php56s .php

    # BEGIN W3TC Browser Cache

    Do you think it’ll still work?

    The other question is what you mean when you put:

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

    Would you please explain what that means? Do we have to do something else with that info?

    Thank you! I really appreciate your help!

    Απάντηση
    • Hi,

      Thanks for the comment. Let me explain you in the detail. When I had written “AMP to non-AMP redirect” code for the first time, it was

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

      But after few months, I noticed that some of my images with file name “amp” were not loading.
      That’s why, I decided to exclude wp-content path completely.

      So, as per my current knowledge, below code is correct and it should work for you.

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

      Here, RewriteCond %{REQUEST_URI} !^/wp-content/(.*)$ means redirection is excluded for static files of wp-content. path.

      I had forget to update my screenshot after updating this thing in the changelogs.
      Thanks for reminding. Due to your question, I felt encouraged to update the screenshot.

      Feel free to use this code, it should work for you. You should add this code just above # BEGIN W3TC Browser Cache since you are using a Cache plugin.

      If you have any more queries, please feel free to ask.

      Thanks & Regards,
      Gulshan

      Απάντηση
      • Thank Gulshan! I am not very tech about stuff like this. Do you think this system works no matter what type of plugins a website has installed ( I mean compatibility) or the type of robot.txt someone has set up?

        As I don’t know much about this stuff I want to be sure I won’t screw my site even more lol. A girl put that AMP plugin on my website saying it would help with my ranking and it was worse! all the tables on my website look completely wrong.

        Thanks Gulshan!

        Απάντηση
  13. Hi Gulshan,

    Thanks for sharing this useful info on rectifying the AMP page errors on how to remove 404 error pages after disabling the AMP plugin

    Please post about more amp errors like user modified javascript errors and user modified css types of amp errors, I am struggling to rectify them, my webmaster reports are flooded with this errors.

    Thanks in advance!!

    Απάντηση