On Fri, Jan 8, 2010 at 4:13 PM, Yiannis <[email protected]> wrote:
> I want my rails app to redirect from no-WWW to WWW domain (for example > if I enter example.com/test to redirect to www.example.com/test). I > put the following code in the application controller and worked fine: > > before_filter :check_uri > def check_uri > if !/^www/.match(request.host) > redirect_to request.protocol + "www." + > request.host_with_port + > request.request_uri, :status => 301 > end > end > > But I also do a simple pages_cache and the above code doesn't execute > when the page is cache. Is any other way to call the above method from > route.rb even when the pages are cached? > > Thank you > > Yiannis, I have always been able to do this type of configuration within my hosting service without touching a .htaccess or httpd.conf files. However, you should be able to do the following for a named virtual host: <VirtualHost *:80> ServerName www.example.com ServerAlias example.com *.example.com DocumentRoot /path/to/rails/app/public </VirtualHost> I take it that you're using Passenger but it's not clear from your original post. Good luck, -Conrad > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > >--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

