I cannot find an example of the specific rewrite rule im attempting.
I would like to have a rewrite rule for only subdomains entered for example.
https://sub.example.com/ -> https://example.com/directory1/directory2/sub
From what ive been trying this looks like the closest code i have got.
server_name example.com;
if ($host = *.example.com)
return 301 https://example.com/directory1/directory2/$1;
}