本文介绍了路由到/ public中的静态html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何路由 / foo
在Rails中显示 /public/foo.html
?
How can I route /foo
to display /public/foo.html
in Rails?
推荐答案
您可以执行以下操作:
将此添加到您的route.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页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!