htaccess/rewrite question

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Reaction score
13
Sup, I get images from a repository on the web, they have their own CDN and the url's are formatted like this:

http://img2.imagerepository.com/images/250x250/product_name/supplier.jpg

img2 can be img/img3/img4 etc

I want to rewrite it so that if I did this:

http://img2.mydomain.com/images/250x250/product_name/supplier.jpg

It would load the image off their server but looking like it came from mine instead.

The RewriteRule I came up with:

RewriteRule ^img(.*)$\.shoppersavvysave\.com/^(.*)$ http://$1.imagerepository.com/$2 [R,L]

Doesn't seem to work.

Any ideas how I'd be able to do this?
 
RewriteRule ^img(.*)$\.shoppersavvysave\.com/^(.*)$ http://$1.imagerepository.com/$2 [R,L]

Looks like an error there. That part is a regex, so $ indicates EOL.

Also, wouldn't you want to specify .jpg as well, otherwise EVERYTHING would be rewritten, wouldn't it?

Hm. Another thing... the substitution variables, $1 and $2.. they would just be the value of the actual matched pattern, IIRC, so matching against:

img1.shoppersavvysave.com/blah would rewrite to 1.imagerepository.com/blah
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X