-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Conditional routing by multiple hosts #9373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The host part is used both for matching and route generating (both by name), you can import an RouteCollection only once per host. If you import the routes they inherit the configuration or there 'parent', if you import them again under a new host these will overwrite the ones previously registered (by there names). If you really need to use multiple hostnames you can also change the host pattern to "^(my.\first.domain|any.other.domain)$" |
Thanks for your reply. Unfortunately I cannot avoid importing the same RouteCollections for both domains, so I tried out the regex: test:
host: "^(my.\first.domain|any.other.domain)$"
resource: "routing.yml" But like in #6848 this doesn't match any domain. |
The problem is that the routes are identified by name, so they are just overridden by the second import using host: "any.other.domain".
Sould be
Please have a look at the routing documentation. Its the same style as for the path pattern. |
Thanks for your suggestion, but using requirements would mean that I had to provide the domain parameter each time I generate a route like described in #6857. Using defaults wouldn't work for me as the user has to stay at the requested domain: test:
host: "{domain}.domain"
resource: "routing.yml"
requirements:
domain: my\.first|any\.other
defaults:
domain: my.first With this config every generated route would point to my.first.domain even if the user requested any.other.domain. |
@tak-amboss As a workarround, as test:
condition: "request.headers.get('Host') matches '^(my.\first.domain|any.other.domain)$'"
resource: "routing.yml" But it's strange for me that pattern is supported by |
This is related to #6848 and #5424. I am trying to use the host matching for changeing my routing resource by domain.
This routing works well for "any.other.domain" but calling by "my.first.domain" I get a NotFoundHttpException. If I change the order of my entries to:
it works well for "my.first.domain" but "any.other.domain" is broken now. Is there a way to get around this problem?
The text was updated successfully, but these errors were encountered: