Nginx rewrite folder redirection

everything...

I am trying to do something in nginx to redirect all file calls to

/images/ 

to enter the:

 /assets/images/ 

can someone help me with rewrite rule? giving 301 permanent status?

+7
redirect nginx rewrite
source share
2 answers

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 details.

+22
source share

Add below configuration to your nginx.conf

 rewrite ^/(images.*) /assets/$1 permanent; 
+2
source share

All Articles