NGINX不应该在目录中寻找目录

  • 本文关键字:寻找 不应该 NGINX nginx
  • 更新时间 :
  • 英文 :


我有此url www.example.com/pl/。nginx处理纠正此URL。另外,我有此URL www.example.com/pl/home。该URL无法正确处理,这些是Nginx的错误:

[error] 6#6: *2 "/usr/share/nginx/html/plhome" is not found (2: No such file or directory), client: 198.108.66.192, server: example.com, request: "GET / HTTP/1.1"

似乎Nginx正在寻找不应该的目录。我希望/pl/pl/prefix nginx将从html/pl/directory中取index.html,然后从那里转到正确的页面。

如果我访问www.example.com/pl/(工作),请从www.example.com/pl/home导航 - 它的工作原理。

我想在浏览器中浏览www.example.com/pl/home,然后查看正确的页面。应该如何设置nginx来处理此操作?

nginx.conf

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        index index.html;
        server_name _;
        location /en {
          root /usr/share/nginx/html;
          index index.html index.htm;
          try_files $uri $uri/ /index.html =404;
        }
        location /pl/  {
          alias /usr/share/nginx/html/pl;
          index index.html index.htm;
          # try_files $uri $uri/ /index.html =404;
        }
} 

我尝试了nginx.conf的许多配置(root而不是别名,位置的regexp)。无法使它起作用。

似乎您应该在PL位置删除拖延斜线: location /pl

相关内容