0

I have a stage and dev server. I periodically pull the database from stage to local, but not the images due to lack of write permissions on stage. I know that you can write rewrite conditions for pulling all images from a remote location, but is there any way to tell Apache to first look on local, and if not found, then grab the images from remote?

1 Answer 1

3

You can use the -f flag in a RewriteCond statement to make a rewriterule conditional on whether or not the file exists locally...and then use a proxy or redirect rule to actually make the image available. This does it using a proxy rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /images/(.*\.(png|jpg)) http://dev/images/$1 [P]

This is not actually a tested configuration, but should hopefully point you in the right direction. The mod_rewrite documentation has a detailed description of RewriteCond an RewriteRule, and a Google search for something like rewritecond file exists will get you useful results.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .