# Remove www with redirect constraints subdomain: 'www' do get ":any", to: redirect(subdomain: nil, path: "/%{any}"), any: /.*/ root to: redirect(subdomain: nil, path: "/"), as: :www_root end # Add www with redirect constraints subdomain: false do get ":any", to: redirect(subdomain: "www", path: "/%{any}"), any: /.*/ root to: redirect(subdomain: "www", path: "/"), as: :non_www_root end
Thanks for your feedback!