【问题标题】:XML sitemap goes to 404 pageXML 站点地图转到 404 页面
【发布时间】:2015-04-16 14:00:01
【问题描述】:

我已经通过 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;

参考:

http://kb.yoast.com/article/16-my-sitemap-is-giving-a-404-error-what-should-i-do

http://kb.yoast.com/article/123-xml-sitemap-errors

http://www.wpbeginner.com/wp-tutorials/how-to-fix-yoasts-wordpress-seo-sitemap-404-error/

http://kb.yoast.com/article/96-enable-xml-sitemaps-in-the-wordpress-seo-plugin

【问题讨论】:

    标签: nginx wordpress


    【解决方案1】:

    我从htpcbeginner 尝试过,效果很好。

    • 我使用的是 Ubuntu 14.04.3 x64,Nginx 1.4.6
    • WordPress 4.4.2

    将以下行放在 yoursite.com 文件中的 location block/etc/nginx/sites-avaliable 并且不要忘记将其重新链接到 /etc/nginx/sites-enabled 文件夹。

    #This rewrite redirects sitemap.xml to sitemap_index.xml, which is what Yoast's WordPress SEO plugin generates.

    rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;

    #This rewrite ensures that the styles are available for styling the generated sitemap.

    rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;

    #These rewrites rule are generated by Yoast's plugin for Nginx webserver.

    rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-02
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 2014-06-11
      相关资源
      最近更新 更多