Joined February 2015
·

Andrej Lacko

Bratislava, SLovakia
·
·

Posted to redirect to canonical host in Rails 4 over 1 year ago

not need to help, the mistake was I wrapped with this constraint "rule" all routes, when I included this only to begining of file everything worked fine.

Posted to redirect to canonical host in Rails 4 over 1 year ago

Hello, this is my code (similar to yours but its non www/ or non www.domain.sk to that domain) :

constraints(:host => /^(?!www.domain\.sk)/i) do
match "/(*path)" => redirect { |params, req| "http://www.domain.sk/#{params[:path]}" }, via: :all

I run the app on heroku and have all other domains with and without subdomain pointed to www.domain.sk with CNAME DNS. When I type any domain combination it redirects me properly to www.domain.sk, but the application shows error. Dont you know where might be the problem? Is it heroku or rails specific error?

Achievements
1 Karma
0 Total ProTip Views