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

Como corrigir o erro 404 do Sitemap do WordPress SEO da Yoast

Nota editorial: Ganhamos uma comissão de links de parceiros no WPBeginner. As comissões não afetam as opiniões ou avaliações de nossos editores. Saiba mais sobre Processo editorial.

Você está tentando corrigir o erro 404 do mapa do site do Yoast SEO no WordPress?

O Yoast SEO é um dos plug-ins de SEO mais populares para WordPress. Devido a um conflito de plug-ins ou a configurações incorretas do WordPress, ele pode mostrar um erro 404 quando você tenta visitar seu sitemap XML.

Neste artigo, mostraremos a você como corrigir facilmente o erro 404 do sitemap XML do Yoast SEO no WordPress.

Fixing Yoast SEO XML sitemap 404 error in WordPress

O que está causando o erro 404 do Sitemap do Yoast SEO no WordPress?

O mapa do site do Yoast SEO ajuda os mecanismos de pesquisa a encontrar todo o conteúdo do seu site que você deseja que eles encontrem e indexem.

A correção do erro garante que os mecanismos de pesquisa possam acessar o mapa do site e descobrir todas as páginas e o conteúdo do site, o que pode resultar em melhor visibilidade e classificação nos mecanismos de pesquisa. Isso também ajudará a classificar seu conteúdo mais rapidamente do que sem um mapa do site.

O WordPress vem com um sitemap XML padrão que você pode enviar ao Google Search Console e a outros mecanismos de pesquisa.

Esse mapa do site em XML pode ser acessado digitando o seguinte URL na barra de endereços do navegador.

https://example.com/sitemap.xml

No entanto, esse mapa do site padrão gerado pelo WordPress é muito básico. Para corrigir isso, todos os principais plug-ins de SEO do WordPress, como o All in One SEO for WordPress ou o plug-in Yoast SEO, criam seus próprios sitemaps XML com mais recursos.

Quando você usa o mapa do site XML gerado pelo seu plug-in de SEO do WordPress, esses plug-ins reescrevem o atalho padrão do mapa do site XML do WordPress.

Isso significa que o URL do mapa do site mencionado acima agora enviará os usuários para os mapas do site gerados pelo seu plug-in de SEO do WordPress.

Infelizmente, isso pode causar um erro 404 em alguns sites devido a conflitos de plugins ou configurações incorretas do WordPress.

Dito isso, vamos dar uma olhada em como corrigir facilmente o erro 404 do mapa do site do WordPress no plug-in Yoast SEO.

1. Atualizar a estrutura de links permanentes do WordPress

O WordPress vem com uma estrutura de URL amigável para SEO (também chamada de permalinks). Essa estrutura de URL usa um sistema de redirecionamento para informar ao seu servidor de hospedagem na Web qual página deve ser carregada quando um usuário digita um URL no navegador.

Normalmente, essas configurações de permalinks são atualizadas automaticamente quando você faz alterações em seu site.

No entanto, às vezes o WordPress pode não conseguir atualizar a estrutura de permalink, o que pode causar o aparecimento do erro 404 do mapa do site do Yoast SEO.

Isso pode ser facilmente corrigido visitando a página Configurações ” Permalinks na área de administração do WordPress e simplesmente clicando no botão “Salvar alterações”.

Update permalinks

Isso atualizará as configurações de permalink do WordPress. Agora você pode visitar a página do sitemap XML para ver se isso resolveu o problema.

Se isso não resolveu o problema, você pode continuar lendo.

2. Atualização manual de Permalinks

Se a atualização da estrutura de links permanentes do WordPress não corrigir o erro 404, você poderá informar manualmente ao servidor da Web para redirecionar os usuários para a página de mapa do site do Yoast SEO.

Para fazer isso, você precisará adicionar o seguinte código ao seu arquivo .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

Observação: Se o seu site WordPress estiver instalado em um subdiretório ou pasta (por exemplo, https://example.com/mywebsite/ ), será necessário usar o seguinte código.

# 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

Não se esqueça de substituir /mywebsite/ pelo nome de seu subdiretório.

Esse código simplesmente informa ao seu servidor da Web quais páginas devem ser exibidas quando os usuários acessarem os sitemaps XML do Yoast SEO.

Agora você pode tentar visualizar o mapa do site XML para ver se isso resolve o problema.

3. Mudar para um plug-in de Sitemaps XML

Se os métodos mencionados acima não resolveram o erro 404 na página do mapa do site XML do Yoast SEO, você pode tentar usar um plug-in separado para gerar mapas do site XML para seu site.

A desvantagem dessa abordagem é que você terá que contar com um plug-in separado para gerar sitemaps XML e com o Yoast SEO para outros recursos de SEO.

Primeiro, você precisa instalar e ativar o plug-in XML Sitemaps. Para obter mais detalhes, consulte nosso guia passo a passo sobre como instalar um plug-in do WordPress.

Como você está usando o Yoast SEO, ele mostrará automaticamente uma notificação para desativar o plug-in XML Sitemaps ou a funcionalidade de mapa do site do Yoast SEO.

Yoast SEO XML Sitemap conflict warning

Clique no botão Toggle Yoast SEO’s XML Sitemap para continuar.

Isso o levará à guia Features (Recursos ) na página SEO ” General (Geral ). A partir daí, você precisa rolar para baixo até a opção XML Sitemaps e desativá-la.

Disabling XML sitemaps in Yoast SEO

Não se esqueça de clicar no botão “Save Changes” (Salvar alterações) para armazenar suas configurações.

Agora você pode alternar para a página Settings ” XML-Sitemap para configurar seus sitemaps. Para a maioria dos sites, as configurações padrão funcionariam imediatamente.

XML Sitemaps settings

Mas você sempre pode definir as configurações de acordo com suas necessidades.

Agora você pode enviar o URL do mapa do site XML para o console de pesquisa do Google e outros mecanismos de pesquisa.

Sitemap URL

4. Mudar para o All in One SEO for WordPress

Se todas as etapas de solução de problemas falharem e você não quiser usar um plug-in separado para gerar sitemaps XML, esse método poderá ajudá-lo a corrigir o problema de erro 404 do sitemap.

Para esse método, você precisará do All in One SEO para WordPress. Ele é o melhor plugin de SEO para WordPress do mercado e uma alternativa muito melhor ao Yoast SEO.

Você pode ver nossa comparação entre Yoast e All in One SEO para obter mais detalhes sobre as diferenças.

O All in One SEO (AIOSEO) vem com sitemaps XML avançados com opções fáceis de gerenciar que lhe dão controle total sobre o que incluir ou excluir dos sitemaps XML.

Primeiro, você precisa instalar e ativar o plug-in All in One SEO para WordPress. Para obter mais detalhes, consulte nosso guia passo a passo sobre como instalar um plug-in do WordPress.

Observação: Há também uma versão gratuita do All in One SEO para WordPress, que inclui a maioria dos recursos de sitemap XML, exceto sitemaps de vídeo e notícias.

Após a ativação, o plug-in o guiará por um assistente de configuração. Você pode seguir nosso guia sobre como configurar corretamente o plugin All in One SEO para WordPress se precisar de ajuda durante a configuração.

All in One SEO setup

O All in One SEO também permitirá que você importe dados de SEO do Yoast SEO.

Isso garante que todas as suas meta tags e títulos de SEO anteriores permaneçam inalterados.

Import Yoast SEO data

Após a configuração inicial, você pode ir para a página All in One SEO ” Sitemaps para definir as configurações do sitemap XML.

All in One SEO sitemaps settings

Você pode clicar no botão Open Sitemap para ver se o erro 404 do mapa do site foi corrigido no WordPress.

Depois disso, você define as configurações do mapa do site, se necessário.

Por exemplo, o All in One SEO permite que você escolha o que incluir em seus mapas de sites. Você pode adicionar ou remover tipos de post, taxonomias, posts individuais e páginas.

All in One SEO sitemaps advanced settings

O All in One SEO também permite que você crie vídeos, notícias, mapas de sites RSS e mapas de sites HTML para o seu site.

Additional sitemaps

Esses sitemaps também podem ser enviados ao Google Search Console e a outros mecanismos de pesquisa. Isso ajuda os mecanismos de pesquisa a encontrar rapidamente o conteúdo mais recente em seu site.

Esperamos que este artigo tenha ajudado você a corrigir o erro 404 do Sitemap do Yoast SEO no WordPress. Talvez você também queira consultar nosso guia completo de solução de problemas do WordPress ou ver como corrigir erros comuns do WordPress.

Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.

Divulgação: Nosso conteúdo é apoiado pelo leitor. Isso significa que, se você clicar em alguns de nossos links, poderemos receber uma comissão. Veja como o WPBeginner é financiado, por que isso é importante e como você pode nos apoiar. Aqui está nosso processo editorial.

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.

O kit de ferramentas definitivo WordPress

Obtenha acesso GRATUITO ao nosso kit de ferramentas - uma coleção de produtos e recursos relacionados ao WordPress que todo profissional deve ter!

Reader Interactions

243 ComentáriosDeixe uma resposta

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

  10. 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!

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

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

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

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

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

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

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

  18. 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();

    }

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

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

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

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

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

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

  25. 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!

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

Deixe uma resposta

Obrigado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossos política de comentários, e seu endereço de e-mail NÃO será publicado. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.