# Remove www with redirect # Add www with redirect but only on production if Rails.env.production? constraints subdomain: 'www' do get ":any", to: redirect(subdomain: nil, path: "/%{any}"), any: /.*/ root to: redirect(subdomain: nil, path: "/"), as: :www_root end end # Add www with redirect but only on production if Rails.env.production? constraints subdomain: false do get ":any", to: redirect(subdomain: "www", path: "/%{any}"), any: /.*/ root to: redirect(subdomain: "www", path: "/"), as: :non_www_root end end