NGINX rewrite rule to redirect directory

Hi

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?

1 Reply

i got it. it was cached.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct