准确地说,我的网站目前正被重定向到appID-appspot.com
如何强制重定向到我的自定义域?
也就是说,当获取" appID-appspot.com"时,重定向到"自定义域"。
答案 0 :(得分:2)
您可以使用express的正则表达式路由匹配。
app.get(/appID-appspot.com/, function (req, res) {
res.redirect('custom_domain');
}
/appID-appspot.com/
与url
匹配并重定向到customdomain。
将上面的内容添加到路线的顶部,以便首先重定向。
答案 1 :(得分:0)
您应该使用res.redirect(301, 'http://example.com');
完整示例:
router.get('/', function(req, res){
res.redirect(301, 'custom domain');
});