I
I
invisii2020-01-18 14:20:12
Nginx
invisii, 2020-01-18 14:20:12

How to redirect all pictures to a folder?

Good day.
Tell me how to redirect all the pictures to a folder, given that they were all in the root of the site.
Example site.com/img.jpg -> site.com/images/img.jpg ; site.com/img.gif-> site.com/images/img.gif
This solution for some reason gives a looped redirect:

RewriteEngine On
RewriteRule ^(.*?)\.(jpg|jpeg|png|gif)$ "/wp-content/uploads/2020/01/$1.$2" [R=301,L]

Need help for both htaccess and nginx

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-01-18
@invisii

RewriteRule ^([^/]+\.(jpe?g|png|gif))$ /wp-content/uploads/2020/01/$1 [R=301,L]

Rewrite ^/([^/]+\.(jpe?g|png|gif))$ /wp-content/uploads/2020/01/$1 permanent;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question