Node.js : 为虚拟主机 (vhost) 使用站点地图
Node.js : Using sitemaps for virtual hosts (vhost)
我是 node.js 的初学者。
目前我正在使用 node.js + express + vhost to host different domains like http://example1.com, http://example2.io 等
如何为每个域 (http://example1.com/sitemap.xml , http://example2.io/sitemap.xml) 提供不同的站点地图?
我看到这个站点地图生成框架:sitemap 这实际上还不错,但我不知道如何将它用于虚拟主机。
对于每个域的 robots.txt 个文件,同样的问题。
好的,我明白了。 sitemap.js 试试吧。
我的代码:
const sm = require('sitemap');
const sitemap = sm.createSitemap({
hostname: 'http://' + req.vhost.host,
cacheTime: 600000
});
sitemap.add({
url: '/page1',
changefreq: 'weekly',
priority: 1.0
});
res.header('Content-Type', 'application/xml');
res.send(sitemap.toString());
我是 node.js 的初学者。 目前我正在使用 node.js + express + vhost to host different domains like http://example1.com, http://example2.io 等
如何为每个域 (http://example1.com/sitemap.xml , http://example2.io/sitemap.xml) 提供不同的站点地图?
我看到这个站点地图生成框架:sitemap 这实际上还不错,但我不知道如何将它用于虚拟主机。
对于每个域的 robots.txt 个文件,同样的问题。
好的,我明白了。 sitemap.js 试试吧。 我的代码:
const sm = require('sitemap');
const sitemap = sm.createSitemap({
hostname: 'http://' + req.vhost.host,
cacheTime: 600000
});
sitemap.add({
url: '/page1',
changefreq: 'weekly',
priority: 1.0
});
res.header('Content-Type', 'application/xml');
res.send(sitemap.toString());