Redirecting www.domain to domain
This is a wiki article created by HostingRails users. Please login or signup to make edits.
I'd like to always redirect www.[my_domain] to [my_domain], so users always nav the site and set cookies without the www. Redirects seem to be for sub-directories only, and I don't have a 'www' subdir to redirect. What's my best option here?
Thank you!
~jw
Resolution if you are running a pack of mongrels (and I assume this is true for a single instance as well): the helpful crew at hosting rails needs to add rewrite rules to the vhost entry in the web server config file. And then it works.
Solution:
have this written on your .htaccess inside the railapp/public
RewriteEngine On
rewritecond %{http_host} ^www\.yourdomain\.org
rewriteRule ^(.*) http://yourdomain.org/$1 [R=301,L]
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Jdub
Chiamingen