• Resolved hadjedj.vincent

    (@hadjedjvincent)


    Hi,

    Here is a little fix for some of us that have 404 errors on the sitemap_index.xml file with WordPress SEO plugin…

    Open your .htaccess file, and add this at the top of it :

    # WordPress SEO - XML Sitemap Rewrite Fix
    <IfModule mod_rewrite.c>
    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]
    </IfModule>
    # END WordPress SEO - XML Sitemap Rewrite Fix

    It should work for most of us !

    https://www.ads-software.com/extend/plugins/wordpress-seo/

Viewing 14 replies - 16 through 29 (of 29 total)
  • Hi Kredacter, glad to hear you got it working. All we’re doing with this fix is telling the server to redirect the requests for the sitemaps to PHP. To get it working with the news module you’ll have to:

    1. Find the sitemap name
    2. Find the PHP query string it should be redirected to
    3. Figure out the rewrite rule and add it your server block

    I haven’t used the news module so I don’t know what those things are, contacting the plugin author might be easiest: https://yoast.com/contact/

    One other thing to check….

    The XSL change in version 1.1.3 and above added the following file to the plugin: wordpress-seo/css/xml-sitemap-xsl.php.

    If you’ve “hardened” your wp-content folder via an .htaccess file to limit file types that browsers can call directly (e.g., to prevent php calls), you’ll need to add the above file as an “exception”.

    After:

    Order Allow,Deny
    Deny from all

    Add:

    <Files "xml-sitemap-xsl.php">
    Allow from all
    </Files>

    Jonathan Warren thanks!
    It’s working on my sites.

    Fixed…see below for Google News Sitemap Rewrite Rule

    Yoast Google News Plugin NGINX Rewrite Rules

    In order to get NGINX to redirect news_sitemap.xml to the sitemap PHP query, you will need to add the following to your server block, it should look something like this:

    server {
    
    	server_name  YourDomain.com;
    	root   /var/www/YourDomain/public;
    
    	#	Fix Yoast SEO Sitemaps
            rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
    	rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
            rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
    }

    This is the additional line that is required for the Google News Sitemap
    rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;

    Then you just need to tell nginx to re-read it’s config files. In Ubuntu use the command service nginx reload. Hope that helps. – from Jonathan Warren.

    I put the code from the very top of this forum to fix my sitemap error 404 problem. It fixed it so the sitemap worked but then all my pages and posts popped up the error 404. Any suggestions?

    hadjedj.vincent YOU ROCK! ??

    Thanks guys, I’m running NGINX and was having this problem… Luckily, WP Community saves the day once again!

    Plugin Contributor Joost de Valk

    (@joostdevalk)

    Nice to see this worked out well for all of you ??

    Plugin Contributor Joost de Valk

    (@joostdevalk)

    Mod, can you resolve this one? I can’t…

    I had a similar problem. Turns out my site was using 1and1 to host, and they still had the site set to PHP4. I changed that setting to PHPdev in the 1and1 Control Panel and it solved the 404 error on sitemap_index.xml

    I had a similar problem with another sitemap xml plugin.

    Google Webmaster Tools complained about a 404 not found for the /sitemap.xml url, but the xml was visible in browser.

    Some testing showed that WordPress adds a 404 header to all feeds, including the sitemap xml feed, if no posts exist in the website.

    Not sure if this affects also the Yoast plugin, but thought I would share the info here for others like me who find this thread when looking for a solution.

    More details and a hotfix here:
    https://www.ads-software.com/support/topic/sitemap-xml-feed-is-shown-but-404-header-added-by-wordpress-if-site-has-no-posts

Viewing 14 replies - 16 through 29 (of 29 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] FIX for sitemap_index.xml 404 error’ is closed to new replies.