Ssl with subdomains


I am writing an application that uses subdomains for the different
customers that access it. For example and

I need to have portions of the application under ssl. I have attempted
different ways of doing Including the following code in my

def redirect_to_ssl

 @cont = controller_name

 @act = action_name

 if !request.subdomains.first.nil?
   @subdomain = request.subdomains.first + '.'
   @subdomain = ''


unless (@request.ssl? or local_request?)


This, however does not work, and i get an error stating that there are
too many redirects.

What is the best way of accomplishing this. If need be I will make the
entire site ssl, but I can’t even figure out how to do that in the
apache.conf because of the subdomains.

Any help would be great!



SSL certificates are typically tied to a specific subdomain. A single
‘Wildcard’ certificate can handle multiple subdomains, but they’re also
considerably more expensive.

Your easiest option is probably to use a wildcard and make the whole
site SSL encrypted. I’ve never used wildcards though, so I can’t
personally vouch for their ease of use.

Thanks for the reply!

I have purchased a wild card domain, the issue is though, have either
apache or my app redirecting to an ssl connection on certain


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs