我在弄清楚如何在nginx.config文件中重定向时遇到了一些困难。
我想从以下几个方面重定向:
http://domain.com/content/uploads/2016/06/img.jpg
至:
http://cdn.domain.com/uploads/2016/06/img.jpg
添加“cdn”在域名之前并删除“内容/”。
我设法添加了“cdn”:
location ~* ^/content/uploads/.*$ {
try_files $uri $uri/ @cdn-domain;
}
location @cdn-domain{
return 301 $scheme://cdn.domain.co.il$request_uri;
}但是,我如何删除“内容/”呢?
发布于 2016-06-27 12:43:34
三百零二
rewrite ^/content/uploads/(.*)$ http://cdn.domain.com/uploads/$1 redirect;301
rewrite ^/content/uploads/(.*)$ http://cdn.domain.com/uploads/$1 permanent;欲了解更多信息:module.html
https://stackoverflow.com/questions/38053713
复制相似问题