我有这个重写规则:
rewrite ^/components/com_jshopping/files/img_products/full_(.*)$ http://www.domain.tdl/components/com_jshopping/files/img_products/$1 permanent;
它将以full_
开头的每个图像请求重定向到没有前缀的同一图像。
现在我只想在请求的图像不存在的情况下应用此规则(404错误)。
我该怎么办?
答案 0 :(得分:2)
您可以将try_files
用于将进行重定向的命名位置:
location /components/com_jshopping/files/img_products/full_ {
try_files $uri @redirect;
}
location @redirect {
rewrite ^(/components/com_jshopping/files/img_products/)full_(.*)$ http://www.domain.tdl$1$2 permanent;
}