0

I'm trying to set the following rule for redirection:

if Rails.env.staging? || Rails.env.production?
        r301 %r{.*}, 'http://mysite.com$&', :if => Proc.new {|rack_env|
            rack_env['SERVER_NAME'] != 'mysite.com' && rack_env['SERVER_NAME'] != '*.mysite.com'
        }
    end

I need my subdomains to be included in the condition, however if I dont something like a.mysite.com it will redirect me to mysite.com all the time.

How can I fix it?

Thanks!

content01
  • 3,115
  • 6
  • 41
  • 61
  • sure you don't want to use a regex to match the subdomains? ```rack_env['SERVER_NAME'] != '*.mysite.com'``` will only match the subdomain ```*.mysite.com``` – phoet Feb 07 '13 at 18:09
  • sure I want to use regex, just dont know what to put there! @phoet – content01 Feb 08 '13 at 03:00
  • so what about googling for how to use a regex? here is a tutorial i found that way http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-regular-expressions/ – phoet Feb 08 '13 at 09:19

0 Answers0