NGINX rewrite rule to redirect directory


I have the following

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

it takes me to

the image name is replaced by a "?" , whys that?

if i try to access

it redirects me correctly to


1 Reply

i got it. it was cached.


Please enter an answer

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] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct