Nginx mutliple rewrite rules per location

If-Is-Evil, avoid using if. You're a starter on nginx and maybe you didn't saw that before (check this guide for a good start). But really, avoid if. And the solution is usually try_files instead.

In your case a unique try_file cannot be used, because you need to apply a special treatment if the zip file is a two character one. But with two locations it should work. Something like that (untested):

location ^~ "/api/([0-9a-zA-Z]{2}).zip"  {
    try_files $uri /api/general.zip;
}
location ^~ "/api/(.*)" {
    try_files $uri $uri/ /api/router.php?rest_data=$1;
}