Ruby on Rails in cPanel

Recently, during a subcontract job, I had cause to use cPanel to set up Ruby on Rails for an app; the contractor I was working with was using UKHost4u who only support it via this method. After a few trials and tribulations, I managed to get a working application running through Mongrel. Now, to get it working on port 80, the cPanel method appeared to be redirecting to Mongrel through Apache. This proved more difficult than expected. After setting it up I had issues with Apache not redirecting correctly and sending files as `text/plain` rather than `text/html` as the browser required.


In cPanel, under “Ruby on Rails”, I was able to set up a link to Mongrel. This wrote a `.htaccess` file in `public_html`, redirecting all requests for the domain to the domain with the port number. However, according to [this Stack Overflow question](http://stackoverflow.com/questions/3608767/you-are-being-redirected-bug-in-rails-2-3-8-mongrel), a bug in Mongrel ([described in lighthouse](https://rails.lighthouseapp.com/projects/8994/tickets/4690)) prevents this method from working out of the box. Adding [this file](http://gist.github.com/471663) into your `config/initializers` folder should patch the problem; add it in and restart Rails.