nginx正在查找目录,但它不应该这样做
我有一个网址www.example.com/pl/。nginx处理更正此url。 此外,我还有一个url www.example.com/pl/home。该url未正确处理,这些是来自nginx的错误:nginx正在查找目录,但它不应该这样做,nginx,Nginx,我有一个网址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: "G
[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/prefix之后,nginx将从html/pl/目录中获取index.html,然后从那里转到正确的页面
如果我转到www.example.com/pl/works,然后从导航到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的许多配置,而不是alias、regexp。无法使其工作。似乎应该删除pl位置中的尾部斜杠:
位置/pl此别名中缺少/。location/pl{alias/usr/share/nginx/html/pl/;try_files$uri$uri//index.html=404;}