Module: Rack

Defined in:
lib/rack/magic-incoming-url.rb

Overview

Magic Incoming URL is a piece of rack middleware that redirects a URL to another one - but only when it’s not from a local link.

It's designed for sites that respond to multiple domains, where different domains should lead to different landing pages.

e.g. You run Simon's Shoes and have two domains: simons-shoes.net and simons-boots.net.
They both point to the same site, but you want customers who go to simons-boots.net to end up
start on the boots page.

http://www.simons-shoes.net -> http://www.simons-shoes.net/
http://www.simons-boots.net -> http://www.simons-boots.net/boots

You can achieve this with the following config:

map '/' do
  use Rack::MagicIncomingUrl, { 'www.simons-boots.net' => { '/' => '/boots' } }
  run MyWebApp
end

Defined Under Namespace

Classes: MagicIncomingUrl