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

查看:191
本文介绍了路由到/ 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页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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