Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have 2 subfolders, they are opened on my_url/test1 and my_url/test2

location /test1 {
    index index.html index.php; ## Allow a static html file to be shown first
    try_files $uri $uri/ /test1 /index.php;
    expires 30d; ## Assume all files are cachable
}

location /test2 {
    index index.html index.php; ## Allow a static html file to be shown first
    try_files $uri $uri/ /test2/index.php;
    expires 30d; ## Assume all files are cachable
}

I want to add 3 additional test subfolders (test3, test4, test5) I can continue writing:

location /test3 {
    index index.html index.php; ## Allow a static html file to be shown first
    try_files $uri $uri/ /test3/index.php;
    expires 30d; ## Assume all files are cachable
}

etc. But May be there is some standart way not to dublicate config? Like

location /(subfolder) {
    index index.html index.php; ## Allow a static html file to be shown first
    try_files $uri $uri/ /(subfolder)/index.php;
    expires 30d; ## Assume all files are cachable
}
share|improve this question

1 Answer 1

You almost got it on your last location statement, just replace /(subfolder) to /, and the subfolder string on the line with try_files to /$uri/index.php instead of /(subfolder)/index.php.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.