0

Let's say I've got a website with multiple (sub)domains:

  • acme.com (USA)
  • acme.nl (Netherlands)
  • be.acme.eu (Belgium)
  • de.acme.eu (Germany)
  • fr.acme.eu (France)
  • etc...

I thought this should be very simple to configure, so I made this routing.yml:

usa: host: "acme.com" resource: "@WebsiteBundle/Controller/" type: annotation defaults: country: "en" netherlands: host: "acme.nl" resource: "@WebsiteBundle/Controller/" type: annotation defaults: country: "nl" europe: host: "{country}.acme.eu" resource: "@WebsiteBundle/Controller/" type: annotation 

But if I run router:debug, only the last route (in this case {country}.acme.eu) shows up. If I change to order, the last option shows up.

How can I use different (sub)domains for all my countries?

2 Answers 2

2

This is because all the routes point to one resource. Every later route will override routes defined before.

But you can use another solution:

main_route: host: "{country}.acme.{domain}" resource: "@WebsiteBundle/Controller/" type: annotation defaults: country: "en" 

Then check in some listener before controller for valid url and process parameters.

Sign up to request clarification or add additional context in comments.

1 Comment

I think you're right that it isn't possible to have multiple routes/hosts pointed to one resource: github.com/symfony/symfony/issues/6857
0

You should use Symfony's hostname routing.

So your routes would look like:

international_homepages: path: / host: "{subdomain}.acme.{extension}" defaults: _controller: AcmeBundle:Main:defaultHomepage subdomain: www extension: com 

1 Comment

Is your answer in compare with mine have something new?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.