Adding Subdomain Requirements to Symfony Routing

Monday, 02 March 2009

Kris Wallsmith just posted a great tutorial showcasing Symfony 1.2's flexibility by demonstrating how to add subdomain requirements to routing.yml:

A question came across the mailing list today that provides an excellent opportunity to demonstrate the flexibility of the symfony 1.2 routing system.

Evert Harmeling posed the following:

How can I point sub1.domain.com/test to a different route than sub2.domain.com/test inside the same application?

This is not supported natively by the symfony core, but the routing system can easily be extended to meet Evert's requirement.

This is a neat extension of Symfony's core. I've written before about using subdomains to load Symfony applications in the same project but this is a bit different as it's switching subdomains within the same Symfony application.