Try with this
location ^~ ^/cat/([0-9]{4})([0-9]{1,4}) {
try_files "/cat/ny/$1/$2.html" @app_server;
}
location @app_server{
# pass this to your app server for processing.
}
- Use ^~ as this will also include the edge case like /cat/12345/ (ending slash).
- And just be sure whether you want $uri (which is without query string) or $request_uri ( which contains query string).