• Resolved davidki

    (@davidki)


    Hello Sybre.

    I use 404 redirection to homepage with this code:

    function redirect_404_error_page_to_homepage(){if($_SERVER[‘REQUEST_URI’] != ‘/sitemap.xml’ && is_404()){wp_redirect(home_url(),301); exit;}} add_action(‘wp’, ‘redirect_404_error_page_to_homepage’, 1);

    I can see sitemap.xml, but only if the sitemap is unstyled (unchecked “Styl Sitemap”).

    When I check option “Styl Sitemap”, sitemap is not generated.

    Firefox display message “Error loading styles: XSLT style parsing failed. “.

    Google Chrome display white screen.

    I tryed re-saving the permalinks, but nothing change.

    I don’t use EasyEngine. I use Apache.

    When I delete redirection 404 on homepage, the sitemap works well even with styling.

    Please, can you advice what can be done, so I can use redirects on homepage and also styling of sitemap?

    Thank you,

    David

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi David,

    You shouldn’t mess with 404 redirects: https://yoast.com/seo-anti-patterns-301-redirect-all-your-404s-to-your-homepage/.

    If you wish to do so, you shouldn’t use wp, but template_redirect. Please also note that the sitemap consists of multiple dynamic parts and reaches complexities beyond a $_SERVER readout. This means that you’ll only get a reliable answer from reading TSF’s sitemap bridge: the_seo_framework()->is_sitemap() (its value is set at template_redirect priority 1). Mind that TSF overwrites the is_404() readout before outputting the sitemap, also at template_redirect priority 1; so, you probably won’t even have to communicate with TSF at all ??

    I hope this helps! Cheers!

Viewing 1 replies (of 1 total)
  • The topic ‘Sitemap.xml returning 404’ is closed to new replies.