Resolve XSLT Errors in WordPress XML Sitemaps

Posted on

This time I just want to share a trivial solution to the problem that might occur if you’re first hosting WordPress using Nginx. Specifically about sitemaps.xml that are usually automatically created by SEO plugins.

Resolve XSLT Errors in WordPress XML Sitemaps

Since it is not Apache/LiteSpeed obviously the htaccess file does not exist and is not recognized, which is where for similar functions in Nginx we have to edit the conf file for its virtual host.

A simple course that I experienced, when activating SEO plugins or sitemap features, opened even appeared an error message:

Previously make sure that you have customized the virtual host configuration for the domain/website per the SEO plugin you are using.

Yoast SEO

#Yoast SEO Sitemaps
location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
## this rewrites sitemap.xml to /sitemap_index.xml
rewrite ^/sitemap.xml$ /sitemap_index.xml permanent;
## this makes the XML sitemaps work
rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 last;
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
## The following lines are optional for the premium extensions
## News SEO
rewrite ^/news-sitemap.xml$ /index.php?sitemap=wpseo_news last;
## Local SEO
rewrite ^/locations.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo-sitemap.xml$ /index.php?sitemap=wpseo_local last;
## Video SEO
rewrite ^/video-sitemap.xsl$ /index.php?yoast-sitemap-xsl=video last;


#rewrite rules for AIOSEOP XML Sitemap v3.1
rewrite ^/sitemap.xml$ /index.php?aiosp_sitemap_path=root last;
rewrite ^/sitemap.xml.gz$ /index.php?aiosp_sitemap_path=root last;
rewrite ^/(.+)-sitemap.xml$ /index.php?aiosp_sitemap_path=$1 last;
rewrite ^/(.+)-sitemap.xml.gz$ /index.php?aiosp_sitemap_path=$1 last;
rewrite ^/(.+)-sitemap(\d+).xml$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 last;
rewrite ^/(.+)-sitemap(\d+).xml.gz$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 last;

After that restart Nginx.

After restarting the error still remains? Don’t worry, I used to be confused, too. Actually, we need to clear the cache.

The next step is to access wp-admin and then go to the Settings menu > Permalink. Instantly Save Changes only and your blog sitemap will be back to normal.

Click to rate this post!
[Total: 0 Average: 0]
Content Protection by

Leave a Reply

Your email address will not be published. Required fields are marked *