(Rails3.2.12)
config/routes.rb
constraints(host: /^(?!www\.)/i) do match '(*any)' => redirect { |params, request| URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s } end
牌語備忘録 -pygo
(Rails3.2.12)
constraints(host: /^(?!www\.)/i) do match '(*any)' => redirect { |params, request| URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s } end