Piotr M
Piotr M

Reputation: 509

nginx is looking for directory when it should not

I have this url www.example.com/pl/. nginx handling correct this url. Also, I have this url www.example.com/pl/home. That url is not correctly handled, those are errors from 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"

Seems like nginx is looking for directories that shouldn't. I want that after /pl/ prefix nginx will take index.html from html/pl/ directory then go to correct page from there.

If I go to www.example.com/pl/ (works) then navigate from to www.example.com/pl/home - it works as it should.

I want to past www.example.com/pl/home in browser and see proper page. How nginx should be set up to handle this?

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;
        }
} 

I tried many configurations of nginx.conf (root instead of alias, regexp in locations). Can't make it work.

Upvotes: 0

Views: 541

Answers (1)

andrey
andrey

Reputation: 628

Seems like you should remove trailing slash in your pl location: location /pl

Upvotes: 1

Related Questions