NGINX rewrite rule to redirect directory
I have the following
domain.com/images/hi.jpg
I want to redirect /images/ to /new/images/hi.jpg
I tried the following but it doesn't work
location ~ /images/(.*)$ {
rewrite ^ /new/images/$1?$args permanent;
}
when I visit
domain.com/images/hi.jpg
it takes me to domain.com/hi/images/?
the image name is replaced by a "?" , whys that?
if i try to access domain.com/images/test.php
it redirects me correctly to domain.com/new/image/test.php
whyy?