nginx 环境下 clean urls 启用后, image styles的问题

这个问题导致 产品缩略图不能自动生成. clean urls 关闭后,正常.

解决办法:

修改 站点的nginx配置文件.  注:红色字为新添加的.

location / {

        index index.php;

        try_files $uri @rewrite;

  }

  location ~ ^/sites/.*/files/styles/ {

        try_files $uri @rewrite;

  }

  location @rewrite {

        rewrite ^ /index.php last;

  }

并重启nginx

 

备注:

[styles]# ll
total 24
drwxr-xr-x 3 nginx nginx 4096 Aug 22 16:05 frontpage_block
drwxr-xr-x 3 nginx nginx 4096 Aug 22 16:05 hp_slideshow
drwxr-xr-x 3 nginx nginx 4096 Aug 22 21:42 product_full
drwxr-xr-x 3 nginx nginx 4096 Aug 22 21:41 product_medium
drwxr-xr-x 3 nginx nginx 4096 Aug 24 13:47 product_thumbnail
drwxr-xr-x 3 nginx nginx 4096 Aug 23 01:40 thumbnail
[styles]# pwd
/root/www/d1p.net/public/sites/default/files/styles

-----------------------------------------------------------------------------------

[public]# pwd
/root/www/d1p.net/public/sites/default/files/styles/product_thumbnail/public
[public]# ll
total 28
-rw-rw-r-- 1 nginx nginx 2768 Aug 24 14:09 test-1.jpg
-rw-rw-r-- 1 nginx nginx 4703 Aug 24 14:09 56d27af095b985e1.jpg
-rw-rw-r-- 1 nginx nginx 3062 Aug 24 14:09 messenger-1v1.jpg
-rw-rw-r-- 1 nginx nginx 3303 Aug 24 14:09 messenger-1v2.jpg
-rw-rw-r-- 1 nginx nginx 3068 Aug 24 14:09 messenger-1v3.jpg
drwxr-xr-x 3 nginx nginx 4096 Aug 24 13:47 modules

故障时,这里的图片删除后不会自动生成.