Redirecting subdomain to folder in Rails 3

拟墨画扇 提交于 2019-12-13 00:13:03

问题


I need to redirect help.mydomain.com/a-page to /pages/a-page without using Nginx or Apache redirects and only through Rails 3 routes.

The key here is the help subdomain determining that /pages/ should be dropped from the route although the view is under the /views/pages/

Any help is appreciated.


回答1:


Try this:

match "/:page_name" => redirect("/pages/%{page_name}"), :constraints => { :subdomain => /help/ }


来源:https://stackoverflow.com/questions/8088174/redirecting-subdomain-to-folder-in-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!