Reputation: 417
I am attempting to exclude all subdomains but still allow www. (optional) And then anything after the domain name is optionally allowed
Here is what I'm looking for:
www.domain.com // true
domain.com // true
sub.domain.com // false
domain.com/hello // true
www.domain.com/hello // true
Here is what I have:
^(?i)(?:www\.)?domain.com.*
This is still allowing other subdomains.
I have tried
^(?i)(?:www\.)(?![-\w.])?domain.com.*
Upvotes: 1
Views: 1202
Reputation: 785098
You can use this regex:
^(www\.)?domain\.com(\/.*)?$
Upvotes: 1