本文介绍了路由到/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')
这篇关于路由到/public 中的静态 html 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!