I understand there are a lot of questions that answer this. I\'m familiar with .htaccess
and nginx.conf
methods, but I do not have access to such t
For Rails 4 the above solutions have to be appended with the Verb construction e.g. via: [:get, :post]
. Duke's solution becomes:
constraints(:host => /^www\./) do
match "(*x)" => redirect { |params, request|
URI.parse(request.url).tap {|url| url.host.sub!('www.', '') }.to_s
}, via: [:get, :post]
end