0

I have images like this - http://www.site1.com/upload/long/long/long/long-path/image.jpg I need redirect all images in folder upload to another site and strip path.

Example site1.com/upload/long/long/long/long-path/image.jpg ---> site2.com/image.jpg

Mod_rewrite instructions I'm trying to construct look like this:

Options +FollowSymLinks
RewriteEngine ON
RewriteCond %{REQUEST_URI} "/upload/"
RewriteCond %{REQUEST_FILENAME} .*\.(jpeg|jpg|gif|png)$
RewriteRule (.+) site2.ru/$1 [QSA,R,L] 

But this code dont strip long path.

0

(.+) captures the whole path. SInce you only want to match the filename, you need to write expressions like ^/upload/.+/([a-z]\.(jpeg|jpg|gif|png))$ instead. Supplement the range a-z to include whatever characters can be in your filename.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.