我们有页面caching与ID分区和子域。 对于像ny.site.com/cat/12345
或la.site.com/dog/234
这样的请求,nginx需要
/cat/ny/1234/5.html
存在,将其返回 request_uri
命中应用程序服务器,即可创buildcaching文件 我们设法找出了子域和id分区的一部分,但没有得到任何try_files部分运气。 在rewrite or internal redirection cycle while internally redirecting to
总会遇到rewrite or internal redirection cycle while internally redirecting to
等无限循环错误
我们的nginx.conf文件就像
rewrite "/cat/([0-9]{4})([0-9]{1,4})" /system/cache/cat/$subdomain/$1/$2.html break; rewrite "/cat/([0-9]{1,4})" /system/cache/cat/$subdomain/$1.html break; try_files $uri $request_uri;
任何提示? 谢谢!
更新:我尝试了以下。 Nginx正在寻找文件系统中的$ request_uri(例如,/ cat / 12345),而不是点击应用服务器。 有什么想法吗?
try_files $uri @old; location @old { rewrite ^ $request_uri break; }
试试这个
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. }
我从来没有试过这个我的自我,但这是我如何写它
location / { # or whatever location you see fit to your requirements try_files $uri.html $uri; # I don't know if the `.` needs to be escaped `$uri\.html`, you can try both }