简体   繁体   中英

How do I route common named controllers by subdomain in rails

I am trying to figure out how to successfully use the same controller name in the URL, but route different controllers. Dependant on the existence of a subdomain.

Example.

http://www.mysite.com/pages/1 Routes to the SitePages Controller

http://anyothersubdomain.mysite.com/pages/1 Routes to the UserPages Controller

Up until now, I have been doing this on the controller level. But it seems like too much logic.

Take a look at the Request Routing and Subdomain Routes plugins. One of those should do the trick for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM