Subdomains and locally installed Rails app

a 夏天 提交于 2019-12-04 01:59:58

you might just want to try putting the actual dot com in your /etc/hosts file.

ie:

127.0.0.1 sub1.myapp.com
127.0.0.1 myapp.com
127.0.0.1 anyothersubdomains.myapp.com

what this usually does is trick your computer into thinking it is the host of all of those, so you can't go to the real site anymore in a web browser.

if you do want it to be .local, presumably so that you can refer to the real online site while working on a local copy, you should probably take a look in app/controllers/application_controller.rb (sometimes application.rb) and look for logic in there that helps determine what to do depending on the subdomain. maybe its hard coded to only look for a .com or something.

If you are using the webrick server or something like Puma for development you can use lvh.me to access your subdomains. e.g.

http://sub.lvh.me:3000/

http://lvh.me:3000/ is equal http://localhost:3000/

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