Q
Q
Quber2015-06-01 18:58:47
symfony
Quber, 2015-06-01 18:58:47

Why Symfony 2 doesn't process regex in router/route?

There is a regular expression that should mean "everything except admin and api":
^(?!.*(admin|api)$).*

# routing.yml
homepage:
    path: /
    host: "{slug}.site.ru"
    defaults:
        _controller: AcmeDemoBundle:Main:homepage
    requirements:
        slug: ^(?!.*(admin|api)$).*

In the address bar I enter admin.site.ru gives a 100% match for this route. 'admin' arrives in slug - 100%
Here www.rubular.com checked the regular expression for correctness. Gives no matches (as it should). And for some reason, Symfony stubbornly produces a 100% method match, as if ignoring the regular expression.
What is the strength in, brother? What am I doing wrong?
Thank you.
============================================ Symfony
routes documentation
2.5.12
=============================================

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
Quber, 2015-06-01
@Quber

The regular expression was not written correctly.
It is right:
^(?!.*(admin|api)).*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question