Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Host regex not matching #6848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MichaelHindley opened this issue Jan 23, 2013 · 5 comments
Closed

Host regex not matching #6848

MichaelHindley opened this issue Jan 23, 2013 · 5 comments

Comments

@MichaelHindley
Copy link

Following http://symfony.com/doc/master/components/routing/hostname_pattern.html

Adding a Host Regex to Imported Routes¶
You can set a host regex on imported routes:

# app/config/routing.yml
acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    host:     "hello.example.com"

The host hello.example.com will be set on each route loaded from the new routing resource.

Trying this with:

acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    host: "/.domain.com|domain.com/"

Fails to match www.domain.com and domain.com, and any other combination.

Debug:

preg_match('/.domain.com |domain.com /', 'www.domain.com', $result);
var_dump($result)
array (size=1)
  0 => string '.domain.com'

Does symfony use something else than preg_match internally or am i missing something ?

@Tobion
Copy link
Contributor

Tobion commented Jan 23, 2013

host options uses the same pattern style with placeholders as the path option.
So it should be like host: {subdomain}.com with requirements: subdomain: example|www.example

@stof
Copy link
Member

stof commented Jan 23, 2013

@Tobion the issue with this is that subdomain becomes a mandatory parameter when generating the url

@Tobion
Copy link
Contributor

Tobion commented Jan 23, 2013

Yes optional placeholders for the host have not been implemented yet.

@Tobion
Copy link
Contributor

Tobion commented Jan 23, 2013

I started work on #5424 which would also cover this feature easily. But don't know when I'm able to complete it.

@stof
Copy link
Member

stof commented Jan 23, 2013

Closing this issue as the answer has been given and the issue with the generation is reported specifically in #6857

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants