【问题标题】:NGINX image resize controllerNGINX 图像调整大小控制器
【发布时间】:2013-03-15 11:01:56
【问题描述】:

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

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

其中 img 是控制器,s 是动作,58x45 是尺寸(要裁剪)。

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

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

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

有什么想法吗?

【问题讨论】:

  • 你用的是女巫CMS吗?
  • 这是一个自定义构建。我继承了它。基于 CodeIgniter。
  • 所以你应该配置CMS路由,检查CodeIgniter路由
  • 你是如何配置nginx的?

标签: php image nginx


【解决方案1】:

你可以通过在 nginx 的 server 块中使用 rewrite 来实现:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多