title: Heroku 301 Redirect
body: <p>How do I make it so <a href="http://domain.com" rel="nofollow">http://domain.com</a> 301 redirects to <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a>? I'm used to using .htaccess to ModRewrite it, but I've learned I can't do that on Heroku.</p>
  
  <p>Example of .htaccess:</p>
  
  <pre><code>Options +FollowSymlinks
  RewriteEngine On
  
  RewriteCond %{HTTP_HOST} ^domain.com [NC]
  RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
  </code></pre>
  
  <p>My file structure:</p>
  
  <pre><code>- /public
  --- /style
  --- index.html
  - config.ru
  </code></pre>
  
  <p>I'm just serving up the single page, and my config.ru consists of this:</p>
  
  <pre><code>use Rack::Static,
  :urls =&gt; ["/style"],
  :root =&gt; "public"
  
  run lambda { |env|
  [
  200,
  {
  'Content-Type' =&gt; 'text/html',
  'Cache-Control' =&gt; 'public, max-age=86400'
  },
  File.open('public/index.html', File::RDONLY)
  ]
  } 
  </code></pre>