如何在 routes.rb 中使用 301 或 302 重定向 [英] How to redirect with a 301 or 302 in the routes.rb

查看:31
本文介绍了如何在 routes.rb 中使用 301 或 302 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 routes.rb 文件中使用 302 重定向?

How can you redirect using a 302 from within the routes.rb file?

推荐答案

您可以在路由语句中将状态传递给重定向.例如,要进行 302 重定向:

You can pass in the status to the redirect in the route statement. For example, to do a 302 redirect:

routes.rb

get '/old/path', to: redirect('/new/path', status: 302)

我希望这对其他人有帮助!

I hope this helps someone else!

这篇关于如何在 routes.rb 中使用 301 或 302 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆