简体   繁体   English

如何添加Nginx重写url + last_part与different_url + last_part?

[英]How can I add nginx rewrite url+last_part with different_url+last_part?

I need to rewrite an nginx rewrite rule, but cant figure out how to do it. 我需要重写nginx重写规则,但无法弄清楚该怎么做。

This is my example URL: 这是我的示例网址:

cdn.example.com/public/storage/upload/images/1/2/3/4.jpg
cdn.example.com/public/storage/upload/images/1/2/3.jpg

I want to convert it to 我想将其转换为

cdn.example.com/storage/app/public/upload/images/1/2/3/4.jpg
cdn.example.com/storage/app/public/upload/images/1/2/3.jpg

I am not sure how can I just add storage/app/ in front of the original URL and remove the storage after public from the original URL? 我不确定如何在原始URL前面添加storage/app/并从原始URL public后删除storage

The regex would be: 正则表达式为:

/public/storage/ /storage/app/public/

Assuming /public/storage/ does not appear anywhere else. 假设/ public / storage /没有出现在其他任何地方。 Otherwise, include the domain name as well. 否则,还应包括域名。 If 'storage' is a pattern, then 如果“存储”是一种模式,则

/public/([a-z]+)/ /$1/app/public/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM