Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
Created August 12, 2011 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daniel-nelson/1142308 to your computer and use it in GitHub Desktop.
Save daniel-nelson/1142308 to your computer and use it in GitHub Desktop.
The goal is for any url elaposentoalto.upperroom.org/abc to be redirected to elaposentoalto.upperroom.org/es/abc
The following correctly redirects elaposentoalto.upperroom.org to elaposentoalto.upperroom.org/es, and it correctly leaves elaposentoalto.upperroom.org/es alone.
However, it incorrectly redirects elaposentoalto.upperroom.org/es/devotional to elaposentoalto.upperroom.org/es/es/devotional.
with_es_subdomains = ['elaposentoalto']
with_es_subdomains.each do |subdomain|
match "" => redirect("/es"), :constraints => { :subdomain => subdomain }
match "/:one" => redirect("/es/%{one}"), :constraints => { :subdomain => subdomain, :one => /([^e].*|e[^s].*|es.+)/ }
match "/:one/:two" => redirect("/es/%{one}/%{two}"), :constraints => { :subdomain => subdomain, :one => /([^e].*|e[^s].*|es.+)/ }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment