admin管理员组文章数量:1426804
To be precise, my website is currently being redirected to appID-appspot
How can I force a redirect to my custom domain ?
That is, when gets "appID-appspot", redirect to "custom domain".
To be precise, my website is currently being redirected to appID-appspot.
How can I force a redirect to my custom domain ?
That is, when gets "appID-appspot.", redirect to "custom domain".
Share Improve this question asked Feb 21, 2017 at 12:43 Coder1000Coder1000 4,50110 gold badges38 silver badges87 bronze badges2 Answers
Reset to default 3You can use regular expression route matching of express.
app.get(/appID-appspot./, function (req, res) {
res.redirect('custom_domain');
}
/appID-appspot./
matches the url
and redirects to customdomain, if the URL contains that part.
Add the above to top of the routes so that it gets redirected first.
You should use res.redirect(301, 'http://example.');
Full example:
router.get('/', function(req, res){
res.redirect(301, 'custom domain');
});
本文标签: javascriptHow to redirect from one domain to another in ExpressStack Overflow
版权声明:本文标题:javascript - How to redirect from one domain to another in Express? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745421897a2657938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论