Nginx XML站点地图转到404页

Nginx XML站点地图转到404页,nginx,wordpress,Nginx,Wordpress,我已经通过yoast安装了wpseo,它没有列出站点地图中的所有链接。 它只是索引xml站点地图 例如: http://domain.com/sitemap_index.xml list the following xml files. When i click any one of the following xml file it goes to 404 page. http://domain.com/post-sitemap.xml http://domain.com/page-site

我已经通过yoast安装了wpseo,它没有列出站点地图中的所有链接。 它只是索引xml站点地图

例如:

http://domain.com/sitemap_index.xml list the following xml files.
When i click any one of the following xml file it goes to 404 page.

http://domain.com/post-sitemap.xml
http://domain.com/page-sitemap.xml
以下是我的nginx配置:

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;
参考:

我试过这个,效果非常好

我使用的是Ubuntu 14.04.3 x64,Nginx 1.4.6 WordPress 4.4.2 将以下行放在中yoursite.com文件的位置块内 /etc/nginx/sites可用,不要忘记将其重新链接到/etc/nginx/sites enabled文件夹

这次重写将sitemap.xml重定向到sitemap_index.xml,这是Yoast的WordPress SEO插件生成的

重写^/sitemap\.xml$/sitemap_index.xml永久

此重写可确保样式可用于设置生成的站点地图的样式

重写^/[a-z]+?-?sitemap\.xsl$/index.php?xsl=$1 last

这些重写规则是由Yoast针对Nginx Web服务器的插件生成的

最后重写^/sitemap\u index\.xml$/index.php?sitemap=1

重写^/[^/]+?-sitemap[0-9]+?\.xml$/index.php?sitemap=$1&sitemap\u n=$2 last

您应该将永久链接更改为/%postname%/。 别忘了重新启动Nginx服务器。 sudo服务nginx重启 这应该对你有用。祝你好运。