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?
You can use the
-f
flag in aRewriteCond
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: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
anRewriteRule
, and a Google search for something like rewritecond file exists will get you useful results.