Connect中的响应重定向 [英] Response redirect in Connect
本文介绍了Connect中的响应重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Express中,我能够使用response.redirect(")重定向到其他URL.同样,如何在Connect模块中重定向?我已经尝试了以下代码,但无法正常工作.
In Express, Im able to redirect to other url using response.redirect(""). Similarly how can I redirect in Connect module? I've tried the below code but its not working.
response.setHeader('Content-Type', 'text/plain');
response.end('<p>302. Redirecting to <a href="' + url+ '">' + url+ '</a></p>');
推荐答案
您还可以使用 writeHead
在Connect中重定向,如下所示:
You can also redirect in Connect using writeHead
as follows:
res.writeHead(301, {Location: url});
res.end();
301状态码表示已永久移动".
The 301 http status code means "moved permanently".
这篇关于Connect中的响应重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文