Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created November 11, 2009 19:11
Show Gist options
  • Select an option

  • Save brandon-beacher/232203 to your computer and use it in GitHub Desktop.

Select an option

Save brandon-beacher/232203 to your computer and use it in GitHub Desktop.
class RedirectController < ApplicationController
def show
uri = URI.parse(request.url)
uri.host = params[:host] if params[:host]
uri.port = params[:port] || 80
if params[:path]
uri.path = params[:path]
else
uri.path = "#{uri.path}/" unless uri.path.include?(".") || uri.path.ends_with?("/")
end
redirect_to uri.to_s
end
end
map.connect "bundlesofhope/*glob", :controller => "redirect", :action => "show", :host => "www.edola.org", :path => "/giving/bundles_of_hope.html", :conditions => { :domain => /edola.org/ }
map.connect "campwrightwood", :controller => "redirect", :action => "show", :path => "/campwrightwood.html", :conditions => { :domain => /ladiocese.org/ }
map.connect "creditunion/*glob", :controller => "redirect", :action => "show", :host => "www.efcula.org", :path => "/", :conditions => { :domain => /ladiocese.org/ }
map.connect "*glob", :controller => "redirect", :action => "show", :host => "ecs.edola.org", :conditions => { :subdomain => "odr" }
map.connect "*glob", :controller => "redirect", :action => "show", :host => "lifeformation.diosohio.org", :conditions => { :subdomain => "anglicanacademy" }
map.connect "*glob", :controller => "redirect", :action => "show", :host => "stpaulsmodesto.diosanjoaquin.org", :conditions => { :subdomain => "stpaulmodesto" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment