New in Symfony 2.4: Restrict Security Firewalls to specific Hosts
![Avatar of Fabien Potencier](https://connect.symfony.com/api/images/4aed4f5d-e0cb-4320-902f-885fddaa7d15.png?format=28x28)
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
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!
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments
![Avatar of Patrik Karisch](https://connect.symfony.com/api/images/d880aaff-85e6-4f23-90bf-80339940996b.png?format=48x48)
![Avatar of Seweryn Zeman](https://connect.symfony.com/api/images/6ee5daa2-de2f-483c-95dc-0f74e0327750.png?format=48x48)
![Avatar of Jacek Jędrzejewski](https://connect.symfony.com/api/images/3a4dc6ce-e3b8-49be-956f-3dd46468c1a5.png?format=48x48)
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.