Routing to static html page in /public

后端 未结 3 1225
北海茫月
北海茫月 2020-12-07 16:06

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

3条回答
  •  抹茶落季
    2020-12-07 16:55

    E.g in Rails 4 add the following route:

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

    Also you need to enable static files from the 'public' directory in your configuration:

    config.serve_static_files = true
    

    OR

    config.serve_static_assets = true
    

    Also you might need to provide your public directory as root in NGINX configuration.

提交回复
热议问题