I have a rails app served via Passenger (mod_rails) that I want to have a canonical URL.
I want all requests to go to http://mydomain.com (so, rewrite http://www.mydomain.com to http://mydomain.com).
On my other non-Rails apps, I accomplish this using mod_rewrite and an .htaccess file with the following:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.+)mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
However, this doesn't seem to work with Passenger. I've tried all sorts of combinations of placing the .htaccess file (in the public directory), and moving the directives around (in the vhost configuration), but I can't get this to work.
How can I accomplish this?