如何配置NGINX以在Angular 5应用程序加载之前呈现sitemap.xml

问题描述 投票:0回答:1

我有一个在NodeJS服务器上运行的Angular 5应用程序,我想在website.com/sitemap/sitemap-cats.xmlexample.com/sitemap/sitemap-dogs.xml上渲染我的站点地图

我的站点地图位于/home/root/sitemap文件夹中。

我已经尝试在/nginx/sites-available/default配置位置块,如下所示,因此它会在Angular应用程序加载之前呈现站点地图。

    # Sitemap Locations
    location /sitemap/sitemap-cats.xml {
            alias /home/root/sitemap/sitemap-cats.xml;
    }

    location /sitemap/sitemap-dogs.xml {
            alias /home/root/sitemap/sitemap-dogs.xml;
    }

问题是上面的配置不起作用,Angular应用程序出于这个原因显示404错误。

甚至可以在Angular应用程序加载之前渲染这些.xml文件吗?

node.js angular nginx nginx-location
1个回答
0
投票

试试这个

# Sitemap Locations
location /sitemap/ {
        alias /home/root/sitemap/;
}
© www.soinside.com 2019 - 2024. All rights reserved.