Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Puchar WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Jak naprawić błąd 404 Sitemap WordPress SEO Yoast?

Radzenie sobie z błędem 404 w twojej mapie witryny Yoast SEO w WordPress może być frustrujące. Yoast SEO jest popularnym narzędziem, ale czasami konflikt wtyczek lub nieprawidłowe ustawienia mogą powodować ten błąd.

Tak więc, jeśli spróbujesz przejść na twoją mapę witryny XML i zobaczysz błąd 404, może cię to zatrzymać. Ale nie martw się, istnieją łatwe poprawki.

W WPBeginner napotkaliśmy i rozwiązaliśmy ten problem, jeśli nie sto razy. W tym artykule poprowadzimy Cię krok po kroku, jak poprawić błąd 404 w mapie witryny Yoast SEO. Postępuj zgodnie z instrukcjami, aby twoja mapa witryny znów działała płynnie.

Fixing Yoast SEO XML sitemap 404 error in WordPress

Co powoduje błąd 404 mapy witryny Yoast SEO w WordPress?

Mapa witryny Yoast SEO pomaga wyszukiwarkom znaleźć wszystkie treści na twojej witrynie internetowej, które mają zostać znalezione i zindeksowane.

Poprawka tego błędu zapewnia wyszukiwarkom dostęp do twojej mapy witryny i odkrywanie wszystkich stron i treści w twojej witrynie. Może to prowadzić do lepszej widoczności i rankingu w wyszukiwarkach, a także pomoże w szybszym pozycjonowaniu twojej treści niż bez mapy witryny.

WordPress ma domyślną mapę witryny XML, którą można przesłać do Google Search Console i innych wyszukiwarek.

Tę mapę witryny XML można przejść na stronę wpisując następujący adres URL w pasku adresu twojej przeglądarki:

https://example.com/sitemap.xml

Jednak ta domyślna mapa witryny generowana przez WordPress jest bardzo podstawowa. Aby to poprawić, wszystkie najlepsze wtyczki WordPress SEO, takie jak Yoast SEO i wtyczka All in One SEO, tworzą własne mapy witryn XML z większą liczbą funkcji.

Kiedy używasz mapy witryny XML wygenerowanej przez twoją wtyczkę WordPress SEO, wtyczka przepisuje domyślny skrót mapy witryny WordPress XML.

Oznacza to, że adres URL mapy witryny wspomniany powyżej będzie następnie wysyłał użytkowników do map witryn wygenerowanych przez twoją wtyczkę WordPress SEO.

Niestety, może to spowodować błąd 404 na niektórych witrynach internetowych z powodu konfliktów wtyczek lub nieprawidłowych ustawień WordPress.

W poniższych sekcjach pokażemy, jak łatwo poprawić błąd 404 mapy witryny WordPress we wtyczce Yoast SEO. Oto krótki przegląd wszystkich metod, które omówimy:

Gotowy? Przejdźmy od razu do rzeczy.

WordPress posiada przyjazną dla SEO strukturę adresów URL, zwaną bezpośrednimi odnośnikami. Ta struktura adresów URL wykorzystuje system przekierowań, aby powiedzieć twojemu serwerowi WWW, którą stronę wczytywać, gdy użytkownik wpisze adres URL w przeglądarce.

Zazwyczaj ustawienia bezpośrednich odnośników są automatycznie aktualizowane po wprowadzeniu zmian w twojej witrynie internetowej.

Zła wiadomość jest taka, że czasami WordPress nie jest w stanie odświeżyć struktury permalinków, co może powodować wyświetlanie błędu 404 mapy witryny Yoast SEO.

To powiedziawszy, można to łatwo poprawić, przechodząc do strony Ustawienia ” Permalinki z obszaru administracyjnego WordPress i po prostu klikając przycisk „Zapisz zmiany”.

Update permalinks

Spowoduje to odświeżenie ustawień bezpośredniego odnośnika WordPress. Możesz teraz przejść na stronę Twojej sitemapy XML, aby sprawdzić, czy poprawiło to Twój problem.

Jeśli to nie poprawiło problemu, to można czytać dalej.

Jeśli odświeżenie struktury permalinków WordPressa nie poprawi błędu 404, możesz ręcznie nakazać serwerowi WWW przekierowanie użytkowników na stronę mapy witryny Yoast SEO.

Aby to zrobić, musisz dodać następujący kod do twojego pliku .htaccess.

# Yoast SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 [L]
# END Yoast SEO - XML Sitemap Rewrite Fix

Uwaga: Jeśli twoja witryna internetowa WordPress jest zainstalowana w podkatalogu lub katalogu (np. https://example. com/mywebsite/ ), musisz użyć następującego kodu.

# Yoast SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /mywebsite/
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 [L]
# END Yoast SEO - XML Sitemap Rewrite Fix

Nie zapomnij zastąpić /mywebsite/ nazwą twojego podkatalogu.

Ten kod po prostu mówi twojemu serwerowi WWW, które strony mają być wyświetlane, gdy użytkownicy uzyskują dostęp do map witryn XML Yoast SEO.

Możesz teraz spróbować zobaczyć twoją mapę witryny XML, aby sprawdzić, czy rozwiązuje to twój problem.

3. Przejście na wtyczkę XML Sitemaps

Jeśli powyższe metody nie rozwiązały błędu 404 na stronie mapy witryny XML Yoast SEO, możesz spróbować użyć osobnej wtyczki do generowania map witryn XML dla twojej witryny internetowej. Dobrą wtyczką do tego celu jest XML Sitemaps plugin.

Wadą tego podejścia jest to, że będziesz musiał polegać na oddzielnej wtyczce do generowania map witryn XML i Yoast SEO dla innych funkcji SEO.

Najpierw należy zainstalować i włączyć wtyczkę XML Sitemaps. Więcej szczegółów można znaleźć w naszym przewodniku krok po kroku, jak zainstalować wtyczkę WordPress.

Ponieważ korzystasz z Yoast SEO, automatycznie otrzymasz powiadomienie o wyłączeniu wtyczki XML Sitemaps lub funkcji map witryn Yoast SEO.

Yoast SEO XML Sitemap conflict warning

Następnie możesz kliknąć przycisk „Toggle Yoast SEO’s XML Sitemap”, aby kontynuować.

Spowoduje to przejście do karty „Funkcje” w sekcji SEO ” Ogólne. W tym miejscu należy przewinąć w dół do opcji „Mapy witryn XML” i wyłączyć ją.

Disabling XML sitemaps in Yoast SEO

Nie zapomnij kliknąć przycisku „Zapisz zmiany”, aby zapisać twoje ustawienia.

Możesz teraz przejść do strony Ustawienia ” XML-Sitemap, aby skonfigurować twoją mapę witryny. W przypadku większości witryn internetowych ustawienia domyślne będą działać po wyjęciu z pudełka.

XML Sitemaps settings

Zawsze jednak możesz skonfigurować ustawienia w oparciu o twoje potrzeby.

Teraz można przesłać adres URL mapy witryny XML do konsoli wyszukiwania Google i innych wyszukiwarek.

Sitemap URL

4. Przejdź na All in One SEO for WordPress

Jeśli wszystkie powyższe sposoby zawiodą i nie chcesz używać oddzielnej wtyczki do generowania map witryn XML, ta metoda może pomóc poprawić problem z błędem mapy witryny 404.

Do tej metody będziesz potrzebować All in One SEO for WordPress. Jest to najlepsza wtyczka WordPress SEO na rynku i znacznie lepsza alternatywa dla Yoast SEO.

Więcej szczegółów na temat różnic można znaleźć w naszym porównaniu Yoast vs All in One SEO.

All in One SEO (AIOSEO) zawiera zaawansowane mapy witryn XML i łatwe w zarządzaniu opcje, które dają pełną kontrolę nad tym, co ma być w nich uwzględnione lub wykluczone.

Najpierw zainstalujmy i włączmy wtyczkę All in One SEO for WordPress. Aby uzyskać więcej informacji, zobacz nasz przewodnik krok po kroku, jak zainstalować wtyczkę WordPress.

Uwaga: Istnieje również darmowa wersja All in One SEO for WordPress, która zawiera większość funkcji mapy witryny z filmami XML, z wyjątkiem filmów i wiadomości.

Po włączaniu wtyczka przeprowadzi Cię przez kreator konfiguracji. Jeśli potrzebujesz pomocy podczas konfiguracji, postępuj zgodnie z naszym przewodnikiem, jak poprawnie skonfigurować wtyczkę All in One SEO dla WordPress.

All in One SEO setup

All in One SEO pozwoli również importować dane SEO z Yoast SEO.

Dzięki temu wszystkie twoje poprzednie meta tagi i tytuły SEO pozostaną niezmienione.

Import Yoast SEO data

Po wstępnej konfiguracji można przejść do strony All in One SEO ” Sitemaps, aby skonfigurować ustawienia mapy witryny XML.

Możesz kliknąć przycisk „Otwórz mapę witryny”, aby sprawdzić, czy poprawiono błąd 404 mapy witryny w WordPress.

All in One SEO sitemaps settings

Następnie w razie potrzeby należy skonfigurować ustawienia mapy witryny.

All in One SEO pozwala na przykład wybrać, co ma być zawarte w twojej mapie witryny. Możesz dodawać lub usuwać typy treści, taksonomie, poszczególne wpisy i strony.

All in One SEO sitemaps advanced settings

All in One SEO umożliwia również tworzenie map witryny z filmami, wiadomościami, RSS i HTML dla Twojej witryny internetowej.

Wystarczy przejrzeć jego karty, aby sprawdzić, czy chcesz skonfigurować więcej ustawień.

Additional sitemaps settings

Te mapy witryn mogą być również przesyłane do Google Search Console i innych wyszukiwarek. Pomaga to wyszukiwarkom szybko znaleźć nowe treści na twojej witrynie internetowej.

Porada eksperta: Nie chcesz sam poprawiać tego błędu WordPressa? Nie martw się – mamy dla Ciebie rozwiązanie! Pożegnaj się z frustrującymi błędami i skup się na tym, co kochasz. Pozwól nam zająć się sprawami technicznymi i zarezerwuj naszą awaryjną pomoc techniczWordPress już teraz!

Mamy nadzieję, że ten artykuł pomógł ci poprawić błąd Yoast SEO Sitemap 404 w WordPress. Następnie możesz również zapoznać się z naszym kompletnym przewodnikiem rozwiązywania problemów WordPress lub zobaczyć, jak poprawić typowe błędy WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Ujawnienie: Nasze treści są wspierane przez czytelników. Oznacza to, że jeśli klikniesz na niektóre z naszych linków, możemy otrzymać prowizję. Zobacz jak WPBeginner jest finansowany, dlaczego to ma znaczenie i jak możesz nas wspierać. Oto nasz proces redakcyjny.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Najlepszy zestaw narzędzi WordPress

Uzyskaj BEZPŁATNY dostęp do naszego zestawu narzędzi - zbiór produktów i zasobów związanych z WordPressem, które każdy profesjonalista powinien mieć!

Reader Interactions

243 komentarzeZostaw odpowiedź

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. CB

    Hi, just tried the second version editing the plug ins core files and the site has disapeared?? including the backend. just a white screen?? I replaced the code withy the original and nothing.

  3. Matt Crystal

    Thank you! That worked by supplying the code in the .htaccess file, then unchecking the site map option and saving. Then, re-checking the box and saving again. Thanks!

  4. Roderick van Straten

    Added this code to the .htaccess and unchecked and checked it, but I only get a blank page now for the sitemap ..

  5. mandingo345

    yes, without fix, just uncheck save recheck and saved.

  6. Jack

    After loosing quite some time trying to find what was wrong, I got it working by your suggestion „Uncheck the sitemap option in the Yoast’s SEO plugin and 'save’ settings. After that re-checking the sitemap’s option fixes the error.”
    tnx very much!

  7. johnny

    Thank you so much! unchecking, saving, rechecking saving did the trick!

  8. sc456a

    After I added the code to htaccess and unchecked/rechecked Sitemap in the plugin, it worked! Thanks!

  9. alireza

    it work for me too, Thanks a lot!

  10. Leo

    Uncheck then save, then go back check again and save, solved my problem. It should be at the begining before anybody try anything else! it worked for me thanks though

  11. Elle Laurel Rose

    Woohoo! Thanks. Mine probably wasn’t broken long because Google didn’t seem to mind yet. … But my site is only in a softer launch stage anyway… Slow crawls maybe. Luckily, I’m improving my site before my real projects go up (hopefully soon).

    Anyway I cannot thank you enough. :)

  12. logitaki

    I opened the class-sitemaps.php file but can’t find the section you are referring to „functiion () init code.. can you be more specific?

  13. Basie

    Editing the .htaccess file, un-checking sitemap generation, saving settings, re-checking, saving settings … fixed it for me! Thank you VERY much.

  14. Tom Atkinson

    I found my issue was actually fixed purely by turning Yoasts sitemaps on and off from UI. Which is great! :)

  15. Fernando

    Were you able to fix this one? I’m having the same problem, I get a 404 on post-sitemap.xml. I didn’t check the PHP logs on what the error is but probably would be the same you’re getting.

    • Steve

      No fix, and theres no replies to support threads on wordpress, other people are just disabling it and using another sitemap plugin.

  16. hayderabbass

    Disabling the XML sitemap and re enabling them fix this issue for me. Thanks!

  17. Ben Billson

    I was having an issue with the sitemap 404’ing when trying to access it.

    I tried adding the first ifmodule, no joy, then remembered I had another ifmodule in place to handle redirects after updating my permalink structure.

    I removed the redirect ifmodule, restarted Worpress SEO, then the sitemaps started working. Re-added the redirect ifmodule, and everything now appears to be working just fine. I’ve also checked the status in GWT and Bing WT and it’s all looking good. Thanks for the help!

  18. Rob Cooper

    I put the first Ifmodule into htaccess and it spit out some weird single line of content, with no links.

    I read through the comments

    then I rebooted Yoast’s sitemap option:

    i unchecked the „Enable XML Sitemap Here” and saved

    I re-checked it and saved

    checked my sitemap and it was there, formatted properly with xsl stylesheet being applied and links all worked

  19. chiappa

    I have no idea where to put that code. There is no line like: „function init()” in class-sitemaps.php

  20. Katrina Isabelle

    Try going into your permalink settings and saving them again. If you can’t access the back end of your site because of the 500 error, then remove that htaccess file.

  21. Katrina Isabelle

    Hello! I think you should add one more step at the very beginning: Re-save your permalink settings! I found that re-saving my permalink settings solved the issue for me. No need to go into the htaccess file.

    • EB

      Exactly, solved my problem too.

    • Alfonso

      this fixed the issue for me, re-saving the WP permalinks

  22. Steve

    I get the following error only on post-sitemap, all other sitemaps work ok:
    Fatal error: Allowed memory size../plugins/wordpress-seo/inc/class-sitemaps.php on line 713
    I tried the htaccess and wpseo-functions edits but no luck.
    I deactivated every plugin, still no luck.
    I deleted wpseo and reinstalled but still same problem and now on the wpseo dashboard and sitemaps page I get this error:
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wpseo_xml_sitemaps_init’ not found or invalid function name in /home/justplay/public_html/wp/wp-includes/plugin.php on line 470

    I have two sites running the same theme, plugins etc and one works ok one has this errors, wierd.

  23. Jane Hockley

    Thank you – i found just by unchecking and saving and then re-checking the site map option for the yoast plugin google webmaster was able to find my site map

  24. Jake Ratliff

    When I tried the htaccess method, it crashed my site. I just added this code into the htaccess file (via the Yoast plugin):

    # WordPress SEO – XML Sitemap Rewrite Fix

    RewriteEngine On
    RewriteBase /
    RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
    RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]

    # END WordPress SEO – XML Sitemap Rewrite Fix

    And then clicked the „save changes to .htaccess” button. I can’t go anywhere without the 500 error now. What did I do wrong? Anyone know how to fix this?

  25. Jake Ratliff

    I tried the htaccess fix and now I get a 500 Internal Server Error.

  26. Tiffany Marie McAnally

    So it still doesn’t work for me… I feel like beating my head against a wall. As much as I love the plugin, I think I’m just going to lose it in favor of something that’s actually functional.

  27. Jérôme Lafforgue

    Thanks, work fine in wpseo-functions.php file @ line 461

  28. ast

    for me worked fine!
    thank you

  29. NicolasJoly

    @Matt Klein, it’s in the wpseo-functions.php file @ line 461

  30. NicolasJoly

    @Matt Klein, the 'init’ function is now 'wpseo_xml_sitemaps_init’ in the wpseo-functions.php, @line 461

    Add just :
    global $wp_rewrite; before the $GLOBALS define
    and
    $wp_rewrite->flush_rules(); after the add_rewrite_rule…

    /**

    * Initialize sitemaps. Add sitemap & XSL rewrite rules and query vars

    */

    function wpseo_xml_sitemaps_init() {

    $options = get_option( 'wpseo_xml’ );

    if ( $options[’enablexmlsitemap’] !== true ) {

    return;

    }

    // redirects sitemap.xml to sitemap_index.xml

    add_action( 'template_redirect’, 'wpseo_xml_redirect_sitemap’, 0 );

    if ( ! is_object( $GLOBALS[’wp’] ) ) {

    return;

    }

    global $wp_rewrite;

    $GLOBALS[’wp’]->add_query_var( 'sitemap’ );

    $GLOBALS[’wp’]->add_query_var( 'sitemap_n’ );

    $GLOBALS[’wp’]->add_query_var( 'xsl’ );

    add_rewrite_rule( 'sitemap_index.xml$’, 'index.php?sitemap=1′, 'top’ );

    add_rewrite_rule( '([^/]+?)-sitemap([0-9]+)?.xml$’, 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]’, 'top’ );

    add_rewrite_rule( '([a-z]+)?-?sitemap.xsl$’, 'index.php?xsl=$matches[1]’, 'top’ );

    $wp_rewrite->flush_rules();

    }

  31. Matt Klein

    There is no function init area in my class-sitemaps.php file. Could it be called something else. What line is it on?

  32. Regina Falkowski

    Added the code to .htaccess file and it worked like a charm! Thanks for the fix :)

  33. Alec Byrne

    Adding the .htaccess worked for me – thanks very much :-)

  34. Ollie

    Htaccess fix worked for me.

    But as Scott in the first comment above says, I needed to uncheck the XML sitemap checkbox and save. Then recheck it and save again for the sitemap to show up. I think that would be worth mentioning in the article.

  35. Steve Patterson

    Thanks this worked for me editing the .htaccess file. I unchecked sitemaps off then back on and also changed mine from 1,000 to 400. If you are on a shared server, I would use a lower number so that less CPU usage is done on your domain.

  36. scott

    Hi guys,

    I had to troubleshoot this issue too. My site is hosted in a sub directory of a main site. So I had to set the following line:

    RewriteBase /scottmortiz/

    I then had to uncheck the mina Site Map XML option in the plugin, and save. Then re-check the plugin and save. Hope this works for some of you.

    -Scott

  37. Chris

    Hi Steven,
    thank alot. This helped me, too. But to get the rewrite working I had to disable the xml function, save it, and enable (and save it) again. Seems obvious, but maybe this is worth a note in the article. I will safe this article in my personal wordpress help register.
    Thanks,
    Chris

    • Dan

      Thank you Chris! This fixed my 404 problem with Yoast’s XML Sitemap feature.

    • Jason Judge

      Ah, switch it off, then switch it back on again. Thanks:-) It is not as obvious as you think. My sitemaps also did not work (getting a 404) until I did this. I did not have to make any of the other changes described in this post.

  38. Shanthi Ganesan

    @PEKKO Hi Tried your techniques it really works well,thanks a lot for sharing….

  39. Lukas

    Nothing is working in my case – still Error 404 …

  40. Ryan

    Beauty, fixed it for me too.. thanks for putting this up

  41. lloyd

    this just broke my websites … now getting an internal server error…

  42. Rosie

    The edit to .htaccess files was just the trick. Thanks for posting this! You saved me a whole lot of time and trouble.

  43. Pekko

    I was just facing the same issue. i unticked the box (Check this box to enable XML sitemap functionality) — pressed save, and then ticked the box again, after that It found the sitemap again, Hope it will be there!

    • Anisa

      I use this technique, and it worked

    • John

      This worked for me, as well. Thx!

    • Cara Sherlock

      Unchecking, saving and then rechecking worked for me too. Thx!

    • Badprimer

      [..unticked the box (Check this box to enable XML sitemap functionality) — pressed save, and then ticked the box again..]

      Worked for me. Thx!! :D

    • Kerry

      Thank you! Worked for me too! So simple. The author of this article should add this too.

    • bruce

      This also worked for me. turn off sitemaps. save. turn them back on. save. fixed

    • David

      Same for me, unchecked, saved, checked, saved, voila!

  44. Steven

    I’ll just share what worked for me, by changing the 'max entries per site map’ to 250 (ie. something less than 1000) I managed to fix the 404 error. I think the server was having issues processing 1000 entries which is the default.

    • Maggie

      Hi Steven, this is great solution! I just fixed the problem by your method. Thank you very much!

    • PromInc

      Thanks Steven – this resolved my issue as well. The 'max entries…’ field was blank for me; simply adding any value seemed to work, which is good as I felt 250 was a bit low. Very simple but effective solution.

    • Nick Root

      That worked thanks for the tip!

Zostaw odpowiedź

Dziękujemy za pozostawienie komentarza. Pamiętaj, że wszystkie komentarze są moderowane zgodnie z naszymi polityka komentarzy, a Twój adres e-mail NIE zostanie opublikowany. NIE używaj słów kluczowych w polu nazwy. Przeprowadźmy osobistą i konstruktywną rozmowę.