I have nginx rewrite rule - it redirects all subdomain requests from sub to folder:
server {
listen x.x.x.x:80;
server_name domain *.domain;
root /home/admin/web/domain/public_html/subs/$subdomain; # here is IF for subdomains
set $subdomain "";
if ($host ~* ^([a-z0-9-\.]+)\.domain$) {
set $subdomain $1;
}
if ($host ~* ^www.domain$) {
set $subdomain "";
}
index index.php;
location / { # here is rules for ROOT domain
root /home/admin/web/domain/public_html;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
........
It work well, but i have one problem.
And in domain and subdomains i have a same php-script that gets data from txt file, like this:
file(key.txt);
My php-fpm module, i think, doesn't know about nginx rules and gets data in SUB from ROOT domain - it's wrong. Please help me to add nginx exceptions or add rule to get txt's data in SUB from SUBs. Not_from_root_domain. Thanks.