如Robby on Rails所述,我已在我的 mac OSX 上成功运行子域。我想遵循下面的示例代码,但我不知道从哪里开始。如何编辑 DNS 设置?我需要有一个专用的虚拟主机来执行此操作吗?现在我有一个标准的(蹩脚的)Dreamhost 共享主机。如果我选择 DVH,Media Temple 是一个不错的选择吗?
任何媒体记录都会有所帮助 - 我的谷歌搜索只会导致愤怒的客户/托管公司长篇大论。
谢谢!
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
before_filter :set_current_account
private
def set_current_account
@current_account = Account.find_by_subdomain!(request.subdomains.first)
end
end
# 4) Tie all top-level requests off the current account
class CustomersController < ApplicationController
def index
@customers = @current_account.customers
end
end