请问 Google XML Sitemaps 的 rewrite rules 写到哪个文件?

问答中心分类: Nginx请问 Google XML Sitemaps 的 rewrite rules 写到哪个文件?
Jack asked 7 年 ago

你好,
我的 WordPress 站点使用 Google XML Sitemaps 插件生成网站地图,提示要将一些 rewrite rules 写到 Nginx 配置文件,请问具体写到哪个位置?
Since you are using Nginx as your web-server, please configure the following rewrite rules in case you get 404 Not Found errors for your sitemap:

rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;


谢谢。

1 Answers
oneinstack answered 7 年 ago
如果vhost.sh选择伪静态为wordpress,可添加在如下文件:

/usr/local/nginx/conf/rewrite/wordpress.conf