nginx dynamic servername with regular expression doesn't work for co.uk
Posted
by
redn0x
on Server Fault
See other posts from Server Fault
or by redn0x
Published on 2013-10-21T14:32:16Z
Indexed on
2013/10/21
15:56 UTC
Read the original article
Hit count: 389
I'm trying to setup a nginx server which dynamically loads content from a folder for a domain. To do this I'm using regular expressions in the server name like so:
server_name ((?<subdomain>.+)\.)?(?<domain>.+)\.(?<tld>.*);
This will create a 3 variables for nginx to use later on, for example when using the following url: test.foo.example.com
this will evaluate to:
- $subdomain = test.foo
- $domain = example
- $tld = com
The problem arises when the co.uk top-level domain is used. In this case when using the url test.foo.example.co.uk
it will evaluate to:
- $subdomain = test.foo.cedira
- $domain = co
- $tld = uk
How can I edit the regular expression so that it will also work for co.uk?
© Server Fault or respective owner