SEO by Yoast sitemap doesn't work on multisite with subdirectories


#1

I am using EasyEngine with WordPress multisite with subdirectories and fastcgi_cache. Everything works great except Sitemap when using SEO by Yoast.

The thing is that sitemap does work for the main site on example.com but it shows only sitemap for the main website and sitemap doesn’t work on any other site such as example.com/site1/ or example.com/site2/ and returns not found error on subdirectory websites.

I am using the latest Easy Engine 2.2.1 updated from 2.1 with Percona MySQL 5.6 and Nginx Helper is installed as well. Sitemap was not working before update, so this shouldn’t be the issue.

Would really appreciate your help with this.


#2

Also default Yoast Sitemap rewrite rules are present in wpcommon.conf


#3

@Silkalns

This is the bug in that plugin. Got to know when searched for similar threads. this will help you

go to Settings > Permalinks on a site that gives the 404 error for the feed URL. Then resave the permalink structure. Then check you sitemap feed URL again…

Reference : https://wordpress.org/support/topic/plugin-xml-sitemap-feed-reach-404-on-subdomains

https://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-read-this-before-you-open-a-new-thread


#4

Thank you for your response!

Unfortunately, this is not the case and resaving permalink structure didn’t help for none of sites that are in the multisite network. However, sitemap does work for the main(root) website.

Since sitemap is working in general, I was thinking that there is some issue with rewrite rules that doesn’t apply for example.com/site1/, example.com/site2/ and other subfolders in my multisite strucutre. Could it be the case?


#5

For anyone else having the same problem fix will come in the upcoming EasyEngine update but you can fix it already.

You should update rewrite rules inside wpcommon.conf file by replacing these lines:

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

With

rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

This simple trick was a lifesaver for me and hope you will find it useful as well.


#6

@Silkalns

Yeah, you got it :smile:

I forgot to update you.


#7

Update is not yet released for everyone, so no harm done :slight_smile:

Thank you!


#8

It seems this is the fix and the rest of the line is identical

However, I’m curious about this entire block:

# Yoast sitemap
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
        rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
        rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
        rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
        rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap$

  # Following lines are options. Needed for WordPress seo addons
        rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
        rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
        rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last;
        rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;

        access_log off;
}

You will notice all of these other directives for news_sitemap locations geo_sitemap and video-sitemap

Should .* be added after ^ on these lines or any other lines within this block?


#9

Hi @Silkalns

It’s been a long time, and we haven’t heard from you. It looks like your issue is resolved.

I am closing this support topic for now. Feel free to create a new support topic if you have any queries further. :slight_smile:


#10