views:

25

answers:

1

I currently have a vhost.conf file, setup for a staging server. The problem I'm running into is that I need to have the staging server actually call (only) images from the production server. So, all other file types will call from the staging server, but any image request pulls data from production server. How would I do this using Apache redirection? This is what I currently have in my vhost.conf file

<LocationMatch ".(jpg|gif|png)$">
    SetHandler None
</LocationMatch>

Any ideas?

A: 
RewriteEngine On
RewriteRule ^(.+)\.(jpg|gif|png)$ http://production.com$1.$2 [L,R]

Should probably work for you

Or try this:

RedirectMatch (.*)\.(gif|jpg|png)$ http://www.anotherserver.com$1.$2
webdestroya
Close! Here's what's being produced:http://www.servername.com/var/www/vhosts/www.servername.com/httpdocs/server_staging/site_media/img/shoe_images/thumbs/5b0881f6fd1ef9b9_thumb.pngIt's appending the file system path, rather than the just the filename.... I need http://staging.servername.com/site_media/ to be: http://www.servername.com/site_media/
Sebastian
Is there anyway I can just replace the host name? so turn "www.servername.com" into "staging.servername.com"?
Sebastian
I updated my answer to use a `RedirectMatch` as I am not sure why the rewrite is adding your folder path.No, you cant just 'change' the hostname, you need to force the page to redirect.
webdestroya
You rule. That did the trick. Thanks man!
Sebastian
No problem, happy to help!
webdestroya