Search code examples
phpwordpress.htaccessseopermalinks

Wordpress Sitemap XML Error while using with Custom Permalinks


I have developed a website on wordpress where I used Yoast SEO plugin (https://wordpress.org/plugins/wordpress-seo/) for SEO and Custom Permalinks (https://wordpress.org/plugins/custom-permalinks/) to customize my links.

Now issue is neither Yoast SEO nor Google Sitemap is able to generate sitemap XML on my website, it returns 404 Error. If i disable Custom Permalinks plugin then it works perfectly.

I even tried changing my Yoast SEO Plugin to All in One SEO but issue remains same, Sitemap only works if custom permalinks is disabled which I can not do because I created custom post type and i must use it.

Did any one use this combination and fixed such issue?

Regards

Manoj Soni


Solution

  • If you use Yoast SEO Plugin they show on their site how to fix it here - http://kb.yoast.com/article/77-my-sitemap-index-is-giving-a-404-error-what-should-i-do

    on an Apache server but make sure you put this in the .htacess before the WordPress code that is in there.

    # 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?xsl=$1 [L]
    # END Yoast SEO - XML Sitemap Rewrite Fix