I have a localization folder that has a bunch of language (as JSON) files, and my webapp tries to read the browser's language to fetch the corresponding JSON file.
In certain scenarios, the corresponding language file does not exist, and nginx returns a 404 as it should. However, I'd like to return a temporary redirect to the default language file.
I've tried this, but it doesn't seem to work. What am I doing wrong?
location /static/l10n {
try_files $uri @missing_language;
}
location @missing_language {
rewrite ^ /static/l10n/en-us.json break;
}
EDIT 2: So I tried tweaking the try_files
a bit like this.
location /static/l10n {
try_files $uri /static/l10n/en-us.json;
}
But now I get a 500 error. The logs say *35 rewrite or internal redirection cycle while internally redirecting
.
EDIT 3: My full nginx conf is here - https://gist.github.com/paambaati/9782e95b2e9af899b154