【问题标题】:Vanilla Forums sitemapindex.xml file inaccessible by nginxnginx 无法访问 Vanilla 论坛 sitemapindex.xml 文件
【发布时间】:2017-02-16 23:17:59
【问题描述】:

我的论坛安装在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;
}

问题是我安装了原版论坛的sitemap plugin

生成的站点地图应该位于

example.com/forums/sitemapindex.xml

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

我该如何解决这个问题?

【问题讨论】:

    标签: nginx vanilla-forums


    【解决方案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;
    }
    

    【讨论】:

    • 我错误地专注于重写。谢谢!这解决了它。
    猜你喜欢
    • 2015-08-16
    • 2018-07-28
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-31
    • 1970-01-01
    • 2013-07-12
    相关资源
    最近更新 更多