jtrupiano / rack-rewrite

A web server agnostic rack middleware for defining and applying rewrite rules. In many cases you can get away with Rack::Rewrite instead of writing Apache mod_rewrite rules.
http://github.com/jtrupiano/rack-rewrite
MIT License
836 stars 80 forks source link

Apply rewrite rule only to certain domain #85

Open cmalpeli opened 7 years ago

cmalpeli commented 7 years ago

My app serves up multiple domains. Is there a way to scope the rewrite to only one of them.

Essentially something that would allow this:

r301 'http://www.domain1.com/something', 'some-other-location'

So http://www.domain1.com/something would redirect, but http://www.domain2.com/something would not.

ShaneBoyer commented 7 years ago

https://github.com/jtrupiano/rack-rewrite#host should work

cmalpeli commented 6 years ago

@ShaneBoyer this solution doesn't actually seem to work for my case.

I've got:

r301 "/app", "/some-marketing-url", host: "www.domain1.com"
r301 "/app", "/another-marketing-url", host: "www.domain2.com"

The first rule applies. But the second redirect gets caught up by the first rule.....