Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
Created August 12, 2011 16:15
Show Gist options
  • Save daniel-nelson/1142386 to your computer and use it in GitHub Desktop.
Save daniel-nelson/1142386 to your computer and use it in GitHub Desktop.
with_es_subdomains = ['elaposentoalto']
with_es_subdomains.each do |subdomain|
match "" => redirect("/es"), :constraints => { :subdomain => subdomain }
match "/:one" => redirect("/es/%{one}"), :constraints => lambda{ |req| req.host =~ /^#{subdomain}\./ && !(req.env["REQUEST_URI"] =~ /^\/es$/) }
match "/:one.:format" => redirect("/es/%{one}.%{format}"), :constraints => lambda{ |req| req.host =~ /^#{subdomain}\./ && !(req.env["REQUEST_URI"] =~ /^\/es\./) }
match "/:one/*path" => redirect("/es/%{one}/%{path}"), :constraints => lambda{ |req| req.host =~ /^#{subdomain}\./ && !(req.env["REQUEST_URI"] =~ /^\/es\//) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment