当我的浏览器,我打电话给http://myhost/tiles/yellow/1/2/3.png ,我期望从http://myhost/cache/yellow.png获得内容我的configuration是以下
location /cache/ { alias /my/path/cache/; } location /tiles/ { try_files $uri $uri/ @rulestiles; } location @rulestiles { rewrite "^/tiles/([a-zA-Z1-9]*)/[0-9]{2}/[0-9]{6}/[0-9]{6}\.png$" /cache/$1\.png permanent; }
我错过了什么? 是否因为我不需要所有参数,所以我不使用捕捉function?
我也不想使用符号链接,因为我只需要几百个真正的文件需要数百万的符号链接…
感谢任何指导/帮助
感谢Alexey Ten在我的问题Alexey Ten评论,我能够纠正我的各种错误。
首先,我的正则expression式是错误的,所以testing时我没有捕获参数
然后,我还将rewrite更改为proxy_pass以保持我的url相同
location /cache/ { alias /my/path/cache/; } location ~ "/tiles/(?<section>[a-zA-Z1-9]*)/[0-9]{1,2}/[0-9]{1,6}/[0-9]{1,6}.png$" { proxy_pass http://my.tested.ip.code/cache/$section.png; proxy_set_header Host $host; }
my.tested.ip.code是服务器IP。