0

I have a single separate wordpress installation inside a subdirectory of another wordpress installation. Subdirectory's name is "blog" (This is not a multisite setup). My rewrite rules for nginx are:

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

  # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain
  rewrite ^.*sitemap_index\.xml$ /index.php?sitemap=1 last;
  rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}

Sitemap is generated for both example.com/sitemap_index.xml and example.com/blog/sitemap_index.xml but both are same and do not contain posts of the second installation in subdirectory(blog). I understand this is related to rewrite rules configuration of subfolder but I am not able to figure out what exactly the problem is. I am using Yoast plugin and have installed Yoast plugins on both the installations i.e root and subfolder separately.

  • What I think both are two different websites completely. Seems you are using EE, note that configurations that are needed to be made in EE differ from the normal configurations out there that are done with plain installations. This is because of the structure of EE differs greatly. I think this would have worked if you had not used EE. The question is, should you have 2 sitemaps, one in the root folder and one in the blog subfolder or just submit both sitemaps together in google. Because even if you have 2 sites, for google its the same site. Try Using different plugin for 2nd one – Ashish Dung Dung May 18 '18 at 23:07
  • Yes a single sitemap with links to both the installation is sufficient. I have tried diff plugin too but I guess rewrite rules for nginx is what is creating the problem and avoiding the links of blog folder to be written in the sitemap. As of now other plugins are also not working. – Subhendu Pratap Singh May 19 '18 at 11:55

1 Answers1

0

I got this working. So basically the problem was nginx rewrite rules which the lastest version of easy engine comes with. Since it is not accustomed by default for single wordpress installations in subdirectory, you need to modify these rules a bit.

so change:

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_n=$2 last;

to

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

Where $dir1 is obviously your subdirectory which you can assign by checking it in location block.