before_filter :set_site
after_filter do |c|
c.class.page_cache_directory= c.site.directory_for(:cache)
endattr_reader:siteprivatedefset_site # Redirect to non-www address before we even hit the database!if request.subdomains.first=="www"if request.subdomains== ["www"]
redirect_to "#{request.protocol}#{request.domain}#{request.port_string}#{request.path}"else
subdomains = request.subdomains.shift.join(".")
subdomains <<"."unless subdomains.blank?
redirect_to "#{request.protocol}#{subdomains}#{request.domain}#{request.port_string}#{request.path}"endelse@site=Site.find_by_host(request.host)
endend