AMPプラグインを無効化した後にAMPページで404を修正する方法

注意:最初に/amp/のページをnoindexにする必要があります

AMPのパーマリンクを非AMPのURLにリダイレクトしたいですか?このガイドがお役に立ちます。

TwitterでもAMPページの配信が開始されたのはご存知かと思います。そのため、古いAMPのWordPressパーマリンクが404ヒットしないようにするために、リダイレクトを使用することは非常に重要です。プラグインを無効にした後, あなたは、すべてのAMPのパーマリンクのためのエラー404が表示されます.

この問題を解決するには、AMPからNON-AMP(canonical)URLへのリダイレクトを設定する必要があります。

  1. Yoast SEO Plugin > Tools > 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]

重要なチェンジログ IST 2017年5月11日 15時15分
wp-content で、名前に ‘amp’ が含まれる可能性のある画像を除外した。

.htaccessをコントロールできない場合は?

また、「Redirection」という無料のプラグインを使って、AMPから非AMPパス(canonical)のページへのリダイレクトを行うことで、404を防ぐことも可能です。

redirection
  1. “Redirection “という無料のプラグインをインストールします。
  2. WordPressダッシュボード>ツール>リダイレクトに移動します。
  3. 新しい301リダイレクトを追加する
  4. ソースを保持する /(.*)\/amp
  5. 対象URL https://www.yourdomain.com/$1

注意:これらの手順は、AMPを適切に無効化/インデックス解除した後に実施する必要があります。

NGINXの場合、AMPをCanonical Redirectに設定するにはどうすればよいですか?

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

.htaccessファイルはどこにあるのでしょうか?🤔

Apache サーバーでは、.htaccess ファイルは通常 public_html ディレクトリにあります。または、Yoast File Editorを使用するか、WP File managerプラグインを経由することも有用です。

.htaccessとRedirectionのどちらを使用すればよいのでしょうか?

もしあなたがApacheのウェブサーバーを使用しているのであれば、.htaccessを使用し、それ以外のプラグインの方法は簡単です。

私のSearch Consoleはまだ404と表示されています

Search Consoleは、データの更新に時間がかかる場合があります。数日待ってから、もう一度確認してください。

このガイドがAMP URLの404を修正するために役立つことを願っています。もし、具体的な質問があれば、お気軽にお尋ねください。ありがとうございました。

コメントする

「AMPプラグインを無効化した後にAMPページで404を修正する方法」への51件のフィードバック

  1. Bhai ek aur doubt 🧐

    is process ko karne ke baad AMP Disable karna hai ye pehle amp disable karna hai uske baad redirection wala process karna hai.

    返信
    • Pehle AMP ko disable karna hai, jab Google par page noindex ho jaaye fir redirect. Maine ye sara cheez article mein likha hai, aap please first line padhiye. 😅

      返信
  2. 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 🙏

    返信
    • Please take a complete back-up of your site.

      Then yes you can safely edit the .htaccess via Rankmath and add it on the first line.

      返信
  3. 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.

      返信
      • Thanks sir
        apne Mera cufusion door Kiya. Kyu ki maine kafi experts se ye sawal pucha tha lekin kisi ne mere comments ka reply nahi diya

        thanks🙏

        Sir ek sawal aur htaccess method ya redirection plugin accha hai.

        返信
  4. Sir, if amp pages are removed from search results after no indexing, will they be redirected to non-amp pages or will non-amp pages be ranked separately?

    返信
    • Once AMP pages are no-indexed completely, OPTIONALLY you can make a choice to redirect from AMP to Non-AMP pages to avoid 404. I have provided snippet for it in the article.

      返信
      • My AMP pages are now properly deindexed. But, my non-amp pages are also deindexed by Google, all of my pages in search results are now disappearing. Should I wait for some time for reindexing of non-amp pages or is this an error? I have followed all the steps correctly according to your article.

        返信
        • Please make sure you have followed this step where I have said removing rel="amphtml" apart from setting noindex of AMP pages.

          返信
          • Yes, I have followed this step by enabling the dev mode in ampforwp plugin as you said in your article.

          • hello sir… i have an error in the page url domain.com/page/19/?amp?nonamp=1&amp

            on my wordpress page, and I want to redirect it to the main domain, how do I put the code in htaccess?

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

    返信
  6. 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

    返信
  7. 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.

    返信
  8. 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.

    返信
  9. 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?

    返信
  10. 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.

      返信
  11. 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

    返信
      • Hey Gulshan,

        I have already redirected all amp errors via the yoast redirect plugin. I heard that redirecting the 404 errors to my homepage is not the best idea but I have already done it. Should I do the .htaccess method as well? Should I also delete the redirects if I do the .htaccess option? What do you recommend I do?

        返信
          • Will using the .htaccess be enough to get rid of the amp errors? I did that and deleted the redirects. Is that okay to do or will the errors come back?

  12. 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?

    返信
  13. Hello Sir,
    I have just deactivated amp plugin but I got trouble
    How to solve this
    I’d like to redirect domain.com/posting/?nonamp=1 to domain.com/posting/
    Thanks

    返信
  14. Hi, I love this except when I test links to my site from SERPS it still takes me to the AMP version of the page. i.e. the URL is actually pointing to a Google server such as https://google.com/amp/s/mypagepath. Is this just because I need to wait until Google de-indexes the AMP version and restores the versions of my pages that point to my server?

    返信
  15. 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

    返信
  16. If you are using Yoast Plugin, just enter the fix provided here in the advanced redirect section of Yoast and it works like charm

    返信
  17. Sorry I was referring to the plugin Real-Time Find and Replace, I should’ve asked this question on the previous page. My mistake.

    返信
  18. 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!

        返信
  19. Hi Bro,

    Shall I know its rewrite the .htaccess files are best or we need to use the redirect plugin?

    Which option is the best bro?

    Can you share the opinion bro?

    Thank you

    返信
  20. 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!!

    返信