【问题标题】:Converting Apache RewiteRule to Nginx's将 Apache RewiteRule 转换为 Nginx 的
【发布时间】:2011-05-19 14:28:50
【问题描述】:

我刚刚安装并运行了 nginx,以便在我的网站上提供静态内容。 它工作得很好,但是关于图像的 apache 重写规则(当然)停止工作。

我不知道如何转换以及在哪个文件中放置 .

这是我在 apache 上使用的:

RewriteCond %{HTTP_REFERER} !^http://(www\.)?imgzzz.com/.*$ [NC]
RewriteRule i/image_(\d+)\.(jpg|jpeg|gif) pic/$1 [L]

其目的是将直接访问的图像重定向到图像页面。

在此先感谢 :) 干杯

【问题讨论】:

  • 请移至 serverfault.com 以获得更好的答案

标签: apache mod-rewrite nginx


【解决方案1】:

k 我自己在做一些研究时找到了答案。把它留在这里以防其他人需要它

location /i/image_ {

location ~ ^/i/image_(?<IMAGE>\d+)\.(jpg|jpeg|gif)$ {
valid_referers imgzzz.com www.imgzzz.com;

if ($invalid_referer) {
rewrite ^ /pic/$IMAGE;
}
}
}

【讨论】:

  • 请选择您的答案作为解决方案
猜你喜欢
  • 2014-09-24
  • 2015-05-21
  • 2011-11-25
  • 2012-07-19
  • 2021-11-26
  • 2021-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多