CuriousNewbie,
This is going to be more requests, but I think the easiest way to do
it is probably to redirect traffic from mysite.com to www.mysite.com,
like you're doing, and then redirect traffic from http: to https:
using something like ssl_requirement.  That way, if somebody visits
http://mysite.com/, they'll be redirected to http://www.mysite.com/
and then redirected again to https://www.mysite.com/.

Tilde Equals


On Dec 1, 1:44 pm, CuriousNewbie <[email protected]> wrote:
> Hello I'm looking to learn how to redirect all non-www (mysite.com) 
> tohttps://www.mysite.com
>
> I tried the following:
>
> class ApplicationController < ActionController::Base
>
>   before_filter :check_uri
>
>   def check_uri
>     redirect_to request.protocol + "www." + request.host_with_port +
> request.request_uri if !/^www/.match(request.host) if Rails.env ==
> 'production'
>   end
>
> Problem with this is since the SSL cert on Heroku is forwww.mysite.com,
> and not mysite.com, the browser throws the nasty SSL HTTPS invalid
> warning.
>
> Any ideas on how to redirect in a way that avoids the nasty SSL HTTPs
> invalid warning?
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to