I am trying to get nginx to work with my pushState-based URI handling that backbone.js manages for me in an Javascript app.
R
I ended up going with this solution:
server {
listen 80;
server_name example.com;
root /var/www/example.com;
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri /index.html;
}
}
This way, at least I still get proper 404 errors if a file isn't found.