htm01
htm01

Reputation: 919

Zend2 Hostname router constraint

I have a typical hostname router as follows :

$route = Hostname::factory(array(
    'route' => ':subdomain.domain.tld',
    'constraints' => array(
        'subdomain' => '??regex??',
    )
));

The problem is that I want to match all the subdomains except 'www'.In other words this router should handle all the subdomains but www.domain.tld. I tried different regex solutions without success. What's the right regex to achieve this ?

Some of the regex solutions I used :

Upvotes: 1

Views: 102

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174836

You may try the below regex.

'^(?!www).*'

This won't allow www at the start.

Upvotes: 1

Related Questions