Rewrite does not work in nginx -


i using nginx1.8.0 in windows10, core configuration tried rewrite request

server {     listen       80;     server_name  localhost;     rewrite ^/qt/(\w+)/(\d+)/(\d+)/(\d+)_(\d+).(\w+)$ /qtfile/$1/$4/$5.$6 last;     # /qt/zoom/x_plus/y_plus/x_y.type   ==>  /qtfile/zoom/x/y.type       location /qtfile {         access_log logs/images.log;         alias   d:/tiles/;     }     location / {         root   d:/www;     } } 

the link http://localhost/qtfile/s/214/7645/102.jpg return right image, link http://localhost/qt/s/214/323/34254/7645_102.jpg throw error:

2015/10/10 10:40:09 [error] 1420#11676: *1 createfile() "d:/www/qt/s/214/323/34254/7645_102.jpg" failed (3: system cannot find path specified), client: 127.0.0.1, server: localhost, request: "get /qt/s/214/323/34254/7645_102.jpg http/1.1", host: "localhost" 

it seems request catched loation / segment.

anything wrong?

it looks regex isn't correct input. gave example http://localhost/qt/s/214/323/34254/7645_102.jpg regex ^/qt/(\w+)/(\d+)/(\d+)/(\d+)_(\d+).(\w+)$. have 2 number segments in regex, 3 in url.

based on url, regex should be:

^/qt/(\w+)/\d+/\d+/\d+/(\d+)_(\d+).(\w+)$ 

you'll have adjust second part of rewrite be

/qtfile/$1/$2/$3.$4 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -