Reputation: 909
small question.
Currently I'm working in DEV Mode on localhost. There I call the API like this.
http://localhost/project/web/app_dev.php/api/get_all
And now I want to add a detection for api subdomain so that I can use the uri above and this one below.
http://api.example.org/get_all
Is this possible? And if yes: Can you give me a idea how this can work?
Maybe via Request-Rewrite in .htaccess
? (Simple)
Or (Complex) via rewriting request on kernel event?
I'm using FOSUserBundle with this routing.yml
.
api:
resource: "@ApiBundle/Controller/"
type: annotation
prefix: /api
defaults: {_format: json}
Upvotes: 1
Views: 965
Reputation: 5026
You could try this as described in How to Match a Route Based on the Host.
api:
resource: "@ApiBundle/Controller/"
type: annotation
path: /
host: "api.example.com"
defaults: {_format: json}
Or use PHP routing to vary the route based on the environment.
But I wouldn't recommend either option.
Upvotes: 1