I have set up a server block on my nginx server, e.g. with domain testsite.com. I want to be able to install separate WordPress installations into direct child folders of the root folders, e.g. /var/www/html/testsite.com/childfolder1, /var/www/html/testsite.com/childfolder2 etc., so they can be reached by testsite.com/childfolder1, testsite.com/childfolder2 etc.
The manual way to create redirects would be to insert it like so:
location /childfolder1 {
index index.php;
try_files $uri $uri/ /childfolder1/index.php?$args;
}
and repeat it for every site to come. Using location / only covers the root directory.
Is there a way to create a (regex?) wildcard rule that says: "For each direct sub directory, apply this try_files command" (which is obviously always the same for WordPress, just the folder names change)?
location /*anydirectsubdirectory* {
index index.php;
try_files $uri $uri/ /*anydirectsubdirectory*/index.php?$args;
}
location / { [...] }sufficient? – gxx Jul 01 '16 at 01:02location / [...]? – gxx Jul 01 '16 at 01:07location /directive is unfortunately not working at all, except for the root directory itself. One of the sites worked after I had used the explicit child directory for location, and after I changed it to/I obviously didn't reload nginx. Now none are working with the default directive. – physalis Jul 01 '16 at 01:48proxy_passandproxy_set_header, usetry_files/indexdirectives. The point there is using regular expression to capture a part of the URI into a variable and using that variable later intry_files. – Tero Kilkanen Jul 01 '16 at 07:34