路由到/public 中的静态 html 页面 [英] Routing to static html page in /public

查看:27
本文介绍了路由到/public 中的静态 html 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Rails 中路由 /foo 以显示 /public/foo.html?

How can I route /foo to display /public/foo.html in Rails?

推荐答案

您可以这样做:

将此添加到您的 routes.rb 文件中.

Add this, into your routes.rb file.

match '/foo', :to => redirect('/foo.html')

更新

在 Rails 4 中,它应该使用get",而不是match":

In Rails 4, it should use "get", not "match":

get '/foo', :to => redirect('/foo.html')

感谢 Grant Birchmeier

这篇关于路由到/public 中的静态 html 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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