---
title: "nginx根据url指定root目录"
author: "ww111"
date: "2016-03-02T13:58:38Z"
tags: []
categories: ["操作系统"]
slug: "nginx-url-root"
draft: false
lastmod: "2016-03-27T11:27:42Z"
id: 2280000
url: "https://ww111.iteye.com/blog/2280000"
---

```
    if ($request_uri ~* "/(v\d+)/.*" ) {
        set $version $1;
    }

    root    /home/code/php/potato/$version/food/public;
```