I've got a working nginx rewrite for a location, but in the case of a specific request I want to rewrite to a different location.
location /api {
if (!-e $request_filename){
rewrite "^/api/.{2}\.zip" /api/general.zip last; break;
rewrite ^/api/(.*)$ /api/router.php?rest_data=$1 last; break;
}
}
So if someone requests /api/uk.zip then it downloads fine, but /api/fr.zip doesn't exist, so it should redirect to /api/general.zip
I've tried 2 location blocks, I get a duplicate location error, and I've tried using 2 if statements, but the second one gets ignored.
If the request is for something else, like /api/events then it should forward to the router page.