Just learning basic NGINX. I am trying to rewrite some clean URLS so they redirect to files in a subdirectory called on the server called views.
The below config accomplishes this. However, whenever I return to the index page, it returns a 404 error.
As you'll see below, I define my index as index.html. I assumed this would ensure that the index.html be treated as the index file. However, it appears NGINX is opting to use the first location block to determine the index. That makes sense because '/' is the index. However, I am attempting to only use that first location block for subsequent pages (ie nginx-practice.test/secondpage)
Here's the config file:
server { listen 127.0.0.1:80; server_name nginx-practice.test; root /usr/robertguttersohn/Sites/nginx-practice/public; index index.html; location ~ /. { root /user/Sites/nginx-practice/public/views; try_files $uri @htmlext =404; } location @htmlext { rewrite ^(.*)$ $1.html last; } access_log /usr/local/var/log/nginx/access.log; error_log /usr/local/var/log/nginx/error.log; } How do I have NGINX use index.html for the index page and then use the rewrite for all subsequent pages?
location = / {}to target index.html file just for the home page.