今天和guanMac童鞋研究的subdomain配置终于有点头绪~~

 之所以会遇到种种难题,个人总结了一下,第一本人太菜,第二英语不好

 贴一下guanMac童鞋配置小结的链接:http://my.eoe.cn/guanmac/archive/6105.html

 在rails4.0中实现二级域名是没有rails3.0中的复杂,只需要几步就可以了!

  步骤如下:

  1. config/routes 中添加

    constraints(Subdomain) do
    get '/' => 'controllerName#actionName'
    end
  2. 在lib文档中添加一个 subdomain.rb
    class Subdomain
    def self.matches?(request) request.subdomain.present? && request.subdomain != "www"
    end
    end
  3. config/application.rb 中添加
    config.autoload_paths += %w(#(config.root)/lib )
  4. 在你的地址栏输入 www.lvh.me:3000 取代你的本地地址。

  • 相关知识点链接
04-25 13:25
查看更多