Redirect images with .htacces - keeping the url

I want to redirect all images calls (.png,.jpg,.jpeg) from a specific folder, to another folder. example.

www.somesite.com/dev/folder1/image1.jpg -> redirect to -> www.somesite.com/folder1/image1.jpg

Thanks

Upvotes: 0

Views: 19

Answers (1)

oTradeMark
oTradeMark

Reputation: 66

This should do it:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)\.(jpg|png|jpeg)$
RewriteRule ^dev/(.*)$ http://www.somesite.com/$1 [R=302,L]

Change the 302 to a 301 for a permanent redirect once you confirm it works (if the images will be moving permanently)

Upvotes: 1

Related Questions