Forum: Ruby on Rails using Thin web server configuration in development , how to have eq. Apache RedirectMatch permanent

Posted by Kad Kerforn (kadoudal)
on 2012-11-15 11:05
(Received via mailing list)
In production, using Apache I can use RedirectMatch permanent to force 
url
wo subdomain to use www.

<VirtualHost *:80>
    ServerName example.com
    RedirectMatch permanent ^/(.*) http://www.example.com/$1
</VirtualHost>

How can I get the same behavior when using Thin in dev mode ?
need to change all  example.com/..   urls into  www.example.com/..   if 
I
don't want to touch the routes  ?

thanks for feedback
Posted by Kad Kerforn (kadoudal)
on 2012-11-15 11:27
(Received via mailing list)
[SOLVED] but using Rails3 routes, maybe there is a better way ?

  host = 
Rails.application.config.action_mailer.default_url_options[:host]

  constraints(:host => host ) do
    root :to => redirect("http://www.#{host}")
    match '/*path', :to => redirect {|params|
"http://www.#{host}/#{params[:path]}"}
  end


Le jeudi 15 novembre 2012 11:03:40 UTC+1, Erwin a crit :
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.