zhishujie
V2EX  ›  问与答

NGINX 环境下需要重写,为了开启 XML 站点地图

  •  
  •   zhishujie · Feb 6, 2015 · 4513 views
    This topic created in 4289 days ago, the information mentioned may be changed or developed.

    Yoast WordPress SEO XML站点地图
    rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
    rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
    请问这个写在什么地方方?linux服务器 nginx

    另外请问下 有没有格式要求。
    实在是不会...求助
    http://www.v2ex.com/i/SoT0n0l0.jpeg

    Supplement 1  ·  Feb 6, 2015
    是wordpress环境下的
    10 replies  •  2015-02-06 13:48:26 +08:00
    sanddudu
    sanddudu
    Feb 6, 2015❤️1
    1
    你的服务器配置文件
    location 那里
    zhishujie
    zhishujie
    OP
    Feb 6, 2015
    2
    @sanddudu 是不是nginx.conf 这个文件?
    sanddudu
    sanddudu
    Feb 6, 2015❤️1
    3
    @zhishujie 要看你网站的配置写在哪,不一定是这个文件
    msg7086
    msg7086
    Feb 6, 2015❤️1
    4
    如果你的nginx是用的deb系统包的话,网站文件在/etc/nginx/sites*下。
    如果你是一键包的话,请去找一键包维护者咨询。
    zhishujie
    zhishujie
    OP
    Feb 6, 2015
    5
    @sanddudu 找到配置文件后 直接将rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
    rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; 这2段代码插到location里随意哪个位置就可以了是么?
    zhishujie
    zhishujie
    OP
    Feb 6, 2015
    6
    @msg7086 用的是luma一件包
    msg7086
    msg7086
    Feb 6, 2015❤️1
    7
    @zhishujie ╮(╯_╰)╭
    插入到 server 段或者 location / 段应该都行。
    zhishujie
    zhishujie
    OP
    Feb 6, 2015
    8
    @msg7086 这里哪个文件是网站的配置文件啊,我刚入门正在学习中,请赐教。
    msg7086
    msg7086
    Feb 6, 2015
    9
    @zhishujie 不敢确定。估摸着是vhost,但是不确定是nginx的还是apache的。
    不用系统包和约定而是要自己搞一套标准的话,就只能靠自己折腾了。
    zhishujie
    zhishujie
    OP
    Feb 6, 2015
    10
    @msg7086 写了2段进去了 网站没有出现问题。谢谢了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3045 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:45 · PVG 18:45 · LAX 02:45 · JFK 05:45
    ♥ Do have faith in what you're doing.