Nginx location rule for Wordpress Multisite in subdirectories

Ian Evans ianevans at digitalhit.com
Tue Aug 28 20:12:52 UTC 2012


On 27/08/2012 4:47 PM, Francis Daly wrote:
> nginx locations can be "regex" or "prefix". If you have a url prefix which
> matches all of the subdir blogs, and none of the non-subdir blogs, then
> something like the following might work (I assume that all subdir blogs
> start with /blogs/blog; and therefore that everything that does not start
> with that pattern belongs to the /blogs location, which remains as-is.):
>
> ==
>    if ($uri ~ (/blogs/[^/]*)) {
>     set $blogname $1;
>    }
>
>    include fastcgi.conf;
>
>    location ^~ /blogs/blog {
>      try_files $uri $blogname/index.php?q=$uri;
>      location ~ php {
>        fastcgi_pass 127.0.0.1:10004;
>      }
>    }
> ==
>
> If you haven't got a clear prefix separation for the blogs, then you
> might want to try a regex location; or perhaps something involving "map"
> which will (probably) require enumeration all of the blogs.


Thanks so much for the example, I'll give it a try.

Is there a specific order the locations have to go in? /blogs before 
/blogs/blog or vice-versa?



More information about the nginx mailing list