Nginx settings:

server { listen 8080 default_server; listen [::]:8080 default_server ipv6only=on; root /var/www/localpikabu.com/html; index index.html; server_name localpikabu.com www.localpikabu.com; location /hi { index hi.html } } 

On localpikabu.com:8080 everything works. When I switch to localpikabu.com:8080/hi , I localpikabu.com:8080/hi 404.

hi.html is in the same folder as index.html . What's wrong?

  • location /hi { try_files hi.html } - Suvitruf ♦
  • Check out error.log - Alexey Ten
  • Hmm, the first version of the question was completely different - andreymal

1 answer 1

To make your construction work, you need:

  • or create a hi directory in the root of the site and move the hi.html file hi.html .
  • or add the alias directive to the location like this:

     location /hi { alias /var/www/localpikabu.com/html; index hi.html; } 
  • or use the try_files directive try_files this:

     location /hi { try_files $uri.html =404; }