nginx rewrite redirect for a folder

后端 未结 2 648
南笙
南笙 2021-02-05 10:53

all...

I am trying to do something in nginx to redirect all calls for files in

/images/

to become in:

/assets/images/
         


        
相关标签:
2条回答
  • 2021-02-05 10:59

    Here's the preferred way to do this with newer versions of Nginx:

    location ~ ^/images/(.*) {
        return 301 /assets/images/$1;
    }
    

    See https://www.nginx.com/blog/creating-nginx-rewrite-rules/ for more info.

    0 讨论(0)
  • 2021-02-05 11:15

    Add below configuration into your nginx.conf

    rewrite ^/(images.*) /assets/$1 permanent;
    
    0 讨论(0)
提交回复
热议问题