Peter Kruithof
Contributed by Peter Kruithof in #8905

Symfony 2.2 introduced host support in the routing system. Symfony 2.4 does the same for the security firewall configuration.

When configuring a firewall, you can restrict it to a given URL path pattern, like ^/admin/:

1
2
3
admin:
    pattern:    ^/admin
    http_basic: true

But what if you want to restrict it to admin.example.com instead? As of Symfony 2.4, this is really easy:

1
2
3
4
host:
    pattern:    ^/
    host:       admin\.example\.com
    http_basic: true

Simple and powerful!

Published in #Living on the edge