express 重定向
Redirects are common in Web Development. You can create a redirect using the Response.redirect()
method:
重定向在Web开发中很常见。 您可以使用Response.redirect()
方法创建重定向:
res.redirect('/go-there')
This creates a 302 redirect.
这将创建302重定向。
A 301 redirect is made in this way:
301重定向是通过以下方式进行的:
res.redirect(301, '/go-there')
You can specify an absolute path (/go-there
), an absolute url (https://anothersite.com
), a relative path (go-there
) or use the ..
to go back one level:
您可以指定绝对路径( /go-there
),绝对URL( https://anothersite.com
),相对路径( go-there
)或使用..
返回上一级: