Tag: 子域名

我可以让Rails / WEBrick将/ etc / hosts中的条目识别为子域(而不是域)吗?

我正在尝试在本地使用子域用于Rails应用程序,因此我将以下行添加到我的/etc/hosts文件中: # add ‘test’ subdomain for localhost 127.0.0.1 test.localhost 现在我可以将浏览器指向test.localhost:3000并点击我的Rails应用程序。 但是,Rails或WEBrick将整个域名解释为域: # logging in the controller logger.debug(“domain: ‘#{request.domain}’, subdomain: ‘#{request.subdomain}'”) # output in the console domain: ‘test.localhost’, subdomain: ” 是否有一种简单的方法可以让WEBrick Rails将test解释为子域? 谢谢! 更新 我最终将before_action作为一种解决方法。 def set_domain_and_subdomain @domain = request.domain @subdomain = request.subdomain # HACK: force /etc/hosts subdomains if Rails.env.development? if m = request.domain.match(/([^\.]+).localhost/) @subdomain = […]

如何在rails中的heroku中添加子域

我有一个ruby on rails的应用程序,它有多个子域,localhost就是这样的 manager.daycare.no:3000/ worker.daycare.no:3000/ daycare.no:3000/ admin.daycare.no:3000/ parent.daycare.no:3000/ 现在我想在heroku上添加这些。 我如何在heroku上添加这些子域名? 我的heroku-app名称是sufa-travels.herokuapp.com/

Ruby中有效子域的正则表达式

我正在尝试validation将用作子域的用户输入字符串。 规则如下: 长度在1到63个字符之间(我从谷歌Chrome浏览器在子域中显示的字符数量中选择63个,不确定它是否实际上是服务器指令。如果您对有效最大长度有更好的建议,我有兴趣听到它) 可能包含a-zA-Z0-9,连字符,下划线 不能以连字符或下划线开头或结尾 编辑:从下面的输入,我添加了以下内容:4。不应包含连续的连字符或下划线。 例子: a => valid 0 => valid – => not valid _ => not valid a- => not valid -a => not valid a_ => not valid _a => not valid aa => valid aaa => valid aaa => valid 0-a => valid a&a => not valid a-_0 => […]