0

I'm trying to redirect wp-content/uploads/(.*)$ to images/$1 but this location doesn't appear to be redirecting - why? Would it be more efficient to use try_files?

 location ^/wp-content/uploads/.*$ {
                rewrite ^/wp-content/uploads/([a-zA-Z\-.]+)$ /images/$1 302;
#               try_files /images/$1 =404;
 }
user3791372
  • 105
  • 4

1 Answers1

1

You missed the ~ operator before location regex, so it's not processed as a regular expression but as a pefixed location. By the way rewrite don't accept 302 flag. Use redirect flag.

Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50