NGINX图像调整大小控制器

时间:2013-03-15 11:01:57

标签: php image nginx

我在使用旧的基于PHP的CMS配置nginx时遇到问题。

PHP创建这样的URL。 http://mysite.com/img/s/58x45/upload/images/gallery/foto/032013/directory/06.jpg

其中img是控制器,是动作,大小是58x45(要裁剪)。

上传/ images / gallery / foto / 032013 / directory / 06.jpg是图片的路径。 路径根据上载文件的目录而变化。

NGINX试图直接访问图像并给我404。

我想让控制器/动作处理它。 (裁剪/保存/提供图像)。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您可以通过在nginx的服务器块中使用重写来实现这一点:

rewrite   ^/img/s/(\d)+x(\d)+/(.)*$ /imageController/imageController.php?width=$1&height=$2&path=$3 last;

这会将其重定向到文件/imageController/imageController.php,其宽度,高度和路径作为变量传入。

相关问题