1

我的论坛安装在 url:example.com/forums

我使用 nginx 和 Vanilla 来“美化”网址。我已经设置

/forum/conf/config.php, “RewriteUrls” to “True”.

在我的 nginx.conf 中:

location /forums {
    index index.php index.htm index.html;
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
        access_log off;
        log_not_found off;
        expires 30d;
    }

    try_files $uri $uri/ @forums;
}

location @forums {
    rewrite ^/forums(.+)$ /forums/index.php?p=$1 last;
}

问题是我安装了香草论坛的站点地图插件

并且生成的站点地图应该位于

example.com/forums/sitemapindex.xml

但是当我在那里导航时,nginx 给了我一个 404。

我该如何解决这个问题?

4

1 回答 1

1

问题是 URI/forums/sitemapindex.xml正在被location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$块处理,而不是被转发到/forums/index.php.

如果您不提供静态.xml文件,您可以简单地|xml从正则表达式中删除该术语。

否则,您需要将该 URI 设为特殊情况,例如:

location = /forums/sitemapindex.xml {
    rewrite ^ /forums/index.php?p=/sitemapindex.xml last;
}
于 2016-10-07T22:36:04.353 回答