我有一个在NodeJS服务器上运行的Angular 5应用程序,我想在website.com/sitemap/sitemap-cats.xml
和example.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文件吗?
试试这个
# Sitemap Locations
location /sitemap/ {
alias /home/root/sitemap/;
}