0

I have a site that let anyone create there own site with our sub-domain and they can also use there own custom domain.

user_site: resource: "routing_user_site.yml" host: "{subdomain}.{domain}" requirements: domain: %domain% defaults: domain: %domain% # Our Site site: host: %domain% resource: "routing_our_site.yml" prefix: / 

The above route works fine, but I'm not sure how to redirect other domains, which is not our main domain to route routing_user_site.yml file

I have added this, but doesn't work

custom_site: host: "{domain}" resource: "routing_user_site.yml" prefix: / requirements: domain: !(%domain%) 

1 Answer 1

1

In Symfony2, the order of the routes is very important. If one route is not matched, then the framework will test the next.

That means, in your case, that you don't have to do !(%domain%), but just to put a rule without any requirement to catch all other routes.

user_site: [...] site: [...] custom_site: resource: "routing_user_site.yml" prefix: / 

If the request is not catched by user_site nor site, it will be catched by custom_site ; and as user_site and site suggest, custom_site will match a user's own domain (or, at least, a domain different from your %domain%).

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.