Regex or wildcard for subdirectories in an Nginx location directive

后端 未结 1 904
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 04:13

I have developers who will be working on their local machines editing multiple Wordpress sites. I\'d like to set up Nginx for them one time without the need for them to edit the

相关标签:
1条回答
  • 2021-01-23 05:01

    You could use a regular expression location to capture the first part of the URI, for example:

    location ~ ^(/[^/]+) {
        try_files $uri $uri/ $1/index.php?$args;
    }
    

    Or use a named location with one or more rewrite statements, for example:

    location / {
        try_files $uri $uri/ @rewrite;
    }
    location @rewrite {
        rewrite ^(/[^/]+) $1/index.php last;
    }
    
    0 讨论(0)
提交回复
热议问题