Answer the question
In order to leave comments, you need to log in
How to dynamically create subdomains in nginx?
Hello!
It is impossible to make dynamically created subdomains for a site in any way. That is, if the user clicks on a link like: sub1.test.ru nginx should look in the F:\Server\OSPanel\domains\localhost\sub1 directory, if the user clicks on a link like othersitename.test.ru nginx should look in the F directory: \Server\OSPanel\domains\localhost\othersitename
Tried like this:
server {
server_name ~^(www\.)?(?<domain>.+)$;
location / {
root F:\Server\OSPanel\domains\localhost\$domain;
}
}
Answer the question
In order to leave comments, you need to log in
^(www\.)?(?<domain>.+)$
sub1.test.ru
sub1
(?:www\.|)
with will (?>www\.|)
exclude a match withwww.test.ru
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question