我已修改 etc/hosts 以将 app.website.local 映射到我的本地主机 127.0.0.1。这有效,它被重定向到我的本地主机。
问题是它request.subdomain
是空的,所以我不能用它做任何事情。
class ApplicationController
before_filter :ensure_domain
private
def ensure_domain
# do something with the request
# here is request.subdomain empty
end
end
我的等/主机:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 app.website.local