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

Come correggere l’errore 404 della sitemap di WordPress SEO di Yoast

State cercando di correggere l’errore 404 della sitemap di Yoast SEO in WordPress?

Yoast SEO è uno dei plugin SEO più popolari per WordPress. A causa di un conflitto tra i plugin o di impostazioni errate di WordPress, potrebbe mostrare un errore 404 quando si cerca di visitare la sitemap XML.

In questo articolo vi mostreremo come correggere facilmente l’errore 404 della sitemap XML di Yoast SEO in WordPress.

Fixing Yoast SEO XML sitemap 404 error in WordPress

Cosa causa l’errore 404 di Yoast SEO Sitemap in WordPress?

La sitemap di Yoast SEO aiuta i motori di ricerca a trovare tutti i contenuti del vostro sito web che volete che trovino e indicizzino.

Correggendo l’errore si garantisce che i motori di ricerca possano accedere alla sitemap e scoprire tutte le pagine e i contenuti del sito, il che può portare a una migliore visibilità e posizionamento sui motori di ricerca. Questo aiuterà anche a classificare i contenuti più velocemente rispetto a quanto avviene senza una sitemap.

WordPress viene fornito con una sitemap XML predefinita da inviare a Google Search Console e ad altri motori di ricerca.

La sitemap XML può essere visitata inserendo il seguente URL nella barra degli indirizzi del browser.

https://example.com/sitemap.xml

Tuttavia, la sitemap predefinita generata da WordPress è molto semplice. Per correggere questo problema, tutti i plugin SEO WordPress in alto, come All in One SEO for WordPress o il plugin Yoast SEO, creano le proprie sitemap XML con più caratteristiche.

Quando si utilizza la sitemap XML generata dal plugin WordPress SEO, questi plugin riscrivono lo scorciatoia predefinita di WordPress XML sitemap.

Ciò significa che l’URL della sitemap di cui sopra invierà gli utenti alla sitemap generata dal plugin SEO di WordPress.

Purtroppo, questo può causare un errore 404 su alcuni siti web a causa di conflitti tra plugin o impostazioni errate di WordPress.

Detto questo, vediamo come correggere facilmente l’errore 404 della sitemap di WordPress nel plugin Yoast SEO.

1. Ricarica della struttura dei Permalink di WordPress

WordPress è dotato di una struttura di URL orientata alla SEO (chiamata anche permalink). Questa struttura di URL utilizza un sistema di reindirizzamento per indicare al server di hosting web quale pagina caricare quando un utente inserisce un URL nel browser.

Di norma, le impostazioni dei permalink vengono aggiornate automaticamente quando si apportano modifiche al sito web.

Tuttavia, a volte WordPress potrebbe non essere in grado di ricaricare la struttura dei permalink, causando la comparsa dell’errore 404 della sitemap di Yoast SEO.

Questo problema può essere facilmente corretto visitando la pagina Impostazioni ” Permalinks nell’area di amministrazione di WordPress e facendo clic sul pulsante “Salva modifiche”.

Update permalinks

In questo modo si ricaricano le impostazioni dei permalink di WordPress. Ora è possibile visitare la pagina della sitemap XML per verificare se il problema è stato corretto.

Se il problema non è stato corretto, potete continuare a leggere.

2. Aggiornamento manuale dei permalink

Se la ricarica della struttura dei permalink di WordPress non corregge l’errore 404, è possibile indicare manualmente al server web di reindirizzare gli utenti alla pagina della sitemap di Yoast SEO.

A tal fine, è necessario aggiungere il seguente codice al file .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

Nota: se il vostro sito web WordPress è installato in una sottodirectory o cartella (ad esempio https://example.com/mywebsite/ ), dovrete utilizzare il seguente codice.

# 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

Non dimenticate di sostituire /mywebsite/ con il nome della vostra sottodirectory.

Questo codice indica semplicemente al vostro server quali pagine visualizzare quando gli utenti accedono alle sitemap XML di Yoast SEO.

Ora si può provare a visualizzare la sitemap XML per vedere se il problema si corregge.

3. Passare a un plugin XML Sitemaps

Se i metodi sopra descritti non hanno risolto l’errore 404 sulla pagina della sitemap XML di Yoast SEO, si può provare a utilizzare un plugin separato per generare sitemap XML per il sito web.

Lo svantaggio di questo approccio è che dovrete affidarvi a un plugin separato per generare sitemap XML e a Yoast SEO per altre caratteristiche SEO.

Per prima cosa, è necessario installare e attivare il plugin XML Sitemaps. Per maggiori dettagli, consultate la nostra guida passo-passo su come installare un plugin di WordPress.

Dato che si utilizza Yoast SEO, verrà mostrata automaticamente una notifica per disabilitare il plugin XML Sitemaps o la funzionalità sitemap di Yoast SEO.

Yoast SEO XML Sitemap conflict warning

Fare clic sul pulsante Attiva/disattiva la Sitemap XML di Yoast SEO per continuare.

Si accede così alla scheda Caratteristiche della pagina SEO ” Generale”. Da qui è necessario scorrere verso il basso fino all’opzione XML Sitemaps e disattivarla.

Disabling XML sitemaps in Yoast SEO

Non dimenticate di fare clic sul pulsante “Salva modifiche” per salvare le impostazioni.

Ora è possibile passare alla pagina Impostazioni ” XML-Sitemap per configurare le sitemap. Per la maggior parte dei siti web, le impostazioni predefinite funzionano subito.

XML Sitemaps settings

Ma è sempre possibile configurare le impostazioni in base alle proprie esigenze.

Ora è possibile inviare l’URL della sitemap XML alla Search Console di Google e ad altri motori di ricerca.

Sitemap URL

4. Passare a Tutto-in-uno SEO per WordPress

Se tutti i passaggi per la risoluzione dei problemi falliscono e non si desidera utilizzare un plugin separato per generare sitemap XML, questo metodo può aiutare a correggere l’errore 404 della sitemap.

Per questo metodo, avrete bisogno di All in One SEO per WordPress. Si tratta del miglior plugin SEO per WordPress presente sul mercato e di un’alternativa molto migliore a Yoast SEO.

Per maggiori dettagli sulle differenze, potete consultare il nostro confronto Yoast vs All in One SEO.

All in One SEO (AIOSEO) è dotato di sitemap XML avanzate con opzioni facili da gestire che consentono di avere il pieno controllo su cosa includere o escludere dalle sitemap XML.

Per prima cosa, è necessario installare e attivare il plugin All in One SEO for WordPress. Per maggiori dettagli, consultate la nostra guida passo-passo su come installare un plugin per WordPress.

Nota: esiste anche una versione gratuita di All in One SEO per WordPress, che include la maggior parte delle caratteristiche delle sitemap XML, ad eccezione di quelle relative a video e notizie.

Dopo l’attivazione, il plugin vi guiderà attraverso una configurazione guidata. Se avete bisogno di aiuto durante la configurazione, potete seguire la nostra guida su come configurare correttamente il plugin All in One SEO per WordPress.

All in One SEO setup

All in One SEO vi permetterà anche di importare i dati SEO da Yoast SEO.

Questo assicura che tutti i meta tag e i titoli SEO precedenti rimangano invariati.

Import Yoast SEO data

Dopo la configurazione iniziale, si può andare alla pagina All in One SEO ” Sitemaps per configurare le impostazioni della sitemap XML.

All in One SEO sitemaps settings

Fate clic sul pulsante Apri Sitemap per verificare se è stato corretto l’errore 404 della sitemap di WordPress.

Successivamente, si configurano le impostazioni della sitemap, se necessario.

Per esempio, All in One SEO consente di scegliere cosa includere nelle sitemap. È possibile aggiungere o rimuovere post type, tassonomie, singoli articoli e pagine.

All in One SEO sitemaps advanced settings

Tutto-in-uno SEO permette anche di creare video, notizie, sitemap RSS e sitemap HTML per il vostro sito web.

Additional sitemaps

Queste sitemap possono anche essere inviate a Google Search Console e ad altri motori di ricerca. Questo aiuta i motori di ricerca a trovare rapidamente i nuovi contenuti del sito web.

Speriamo che questo articolo vi abbia aiutato a correggere l’errore 404 di Yoast SEO Sitemap in WordPress. Potreste anche voler consultare la nostra guida completa alla risoluzione dei problemi di WordPress o vedere come correggere gli errori più comuni di WordPress.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

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.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

243 commentiLascia una risposta

  1. Syed Balkhi says

    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 says

    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 says

    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. Jack says

    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!

  5. Leo says

    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

  6. Elle Laurel Rose says

    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. :)

  7. logitaki says

    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?

  8. Basie says

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

  9. Tom Atkinson says

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

  10. Fernando says

    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 says

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

  11. Ben Billson says

    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!

  12. Rob Cooper says

    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

  13. chiappa says

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

  14. Katrina Isabelle says

    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.

  15. Katrina Isabelle says

    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.

  16. Steve says

    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.

  17. Jane Hockley says

    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

  18. Jake Ratliff says

    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?

  19. Tiffany Marie McAnally says

    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.

  20. NicolasJoly says

    @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();

    }

  21. Matt Klein says

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

  22. Ollie says

    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.

  23. Steve Patterson says

    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.

  24. scott says

    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

  25. Chris says

    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

    • Jason Judge says

      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.

  26. Rosie says

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

  27. Pekko says

    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!

  28. Steven says

    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.

    • PromInc says

      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.

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.