0

How do you forward all requests without subdomain to a subdomain?

I want all domain.com requests to go to api.domain.com

it's for an angular app which calls get "/resources" etc. so api.domain.com/resources works but domain.com/resources does not

rails 4

max
  • 96,212
  • 14
  • 104
  • 165
Gambai
  • 651
  • 1
  • 7
  • 25
  • This could be done in you HTTP Server http://stackoverflow.com/questions/10294481/how-to-redirect-a-url-in-nginx – AbM May 08 '15 at 22:49
  • I'm sorry. I don't know how to get to the server block. also, this would need to be done in rails, not a server so it can be passed on git – Gambai May 08 '15 at 23:10

1 Answers1

0

in application controller as a before_action

    unless request.url.to_s.include? 'api'
        redirect_to subdomain: 'api' and return
    end
Gambai
  • 651
  • 1
  • 7
  • 25