0.0
No commit activity in last 3 years
No release in over 3 years
Rack middleware that will redirect all request that are not from the specified domain
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.6
>= 0
 Project Readme

ForceDomain

Rack middleware that will redirect all request that are not from the specified domain

Useful for redirecting website.herokuapp.com to www.website.com

Installation

Add this line to your application's Gemfile:

gem 'force_domain'

And then execute:

$ bundle

Or install it yourself as:

$ gem install force_domain

Usage

If your using Rails, the middleware will be inserted automatically

Otherwise you have to insert it manually

use ForceDomain::Middleware

Now all you need to do is set the environment key APP_DOMAIN to your specific domain

Example:

heroku config:set APP_DOMAIN=www.website.com

All requests made to website.herokuapp.com will now 301 redirect to www.website.com keeping path and query parameters

You can allow multiple domains by adding them to APP_DOMAIN seperated by comma. In case of a redirect then the first mentioned domain will be used.

Contributing

  1. Fork it ( https://github.com/askehansen/force_domain/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request