nginx更改specyfic url的根文件夹

我有一个如下所示的configuration文件:

    服务器{

        听80;
         server_name localhost;

         #charset utf-8;
         root html / laravel / public;
         index index.html index.php;

         #browse文件夹如果没有索引文件
         autoindex on;

         #强制没有www
         if($ host〜* ^ www \。(。*))
         {
            设置$ host_without_www $ 1;
            重写^ /(。*)$ $ scheme:// $ host_without_www / $ 1 permanent;
         }

         #直接提供静态文件
        位置〜*。(jpg | jpeg | gif | css | png | js | ico | html)$ {
             access_logclosures;
             #expires max;
         }

         #删除尾部斜线(防止SEO重复的内容问题)
        如果(!-d $ request_filename)
         {
            重写^ /(。+)/ $ / $ 1永久;
         }

         #canonicalize codeigniter url结束点
         #如果你的默认控制器是“欢迎”以外的东西,你应该改变以下内容
         #if($ request_uri〜* ^(/ lobby(/ index)?/ index(.php)?)/?$)
         #{
         #重写^(。*)$ /永久;
         #}

         #从所有控制器中删除尾随“索引”
        如果($ request_uri〜* index /?$)
         {
            重写^ /(。*)/ index /?$ / $ 1永久;
         }

         #除非请求是一个有效的文件(图像,JS,CSS等),发送到引导
        如果(!-e $ request_filename)
         {
            重写^ /(。*)$ /index.php?/$1 last;
            打破;
         }

         #将服务器错误页面redirect到静态页面/50x.html
         #
         error_page 500 502 503 504 /50x.html;
         location = /50x.html {
            根html;
         }

        位置/后端/ {
             root / html / frontend;
         }

        位置〜\ .php $ {
            包括fastcgi.conf;
             fastcgi_pass 127.0.0.1:9000;
             fastcgi_index index.php;
            包括fastcgi_params;
         }

         location〜/\.ht {
            否认一切;
         }

         #抓住一切
         #error_page 404 /index.php;

         #location〜\ .php $ {
         #try_files $ uri = 404;
         #fastcgi_pass unix:/tmp/php.socket;
         #fastcgi_index index.php;
         ##include fastcgi_params;
         #include / home / tamer / code / nginx / fastcgi_params;
         #}
         #access_log /home/tamer/code/laravel/storage/logs.access.log;
         #error_log /home/tamer/code/laravel/storage/logs.error.log;
     }

我必须将根文件夹更改为html/backend以获取具有$host/backend/任何url。 加载页面的所有规则必须相同,只有根文件夹必须更改。

我怎样才能做到这一点?

server_name添加127.0.0.1即可使用您在注释127.0.0.1提供的链接

 server_name localhost 127.0.0.1; 

你还需要在里面有rootbackend位置。

 location /backend/ { root /html/backend; }