The question is : Can I somehow configure Apache to use alternative directory, or rather to search alternative directory first, and if file is found then to use that one, rather than the original.

Say I have a configuration like this :


as well as:


Now, the file in second location may or may not be present. If its present I would like that one to be used instead of the one in mysite. Is that possible to do with Apache virtual host configuration (custom_theme folder will vary depending on the domain used to access the site)?


Assuming /var/www/ is your DocumentRoot, so both the: mysite and the: custom_theme directories are directly and publicly accessible, then you could achieve what you want via a re-write rule e.g.

RewriteEngine On

RewriteCond %{REQUEST_URI}                  ^/mysite/images/([^/]+\.jpg)$              
RewriteCond /var/www/custom_theme/images/%1 -f
RewriteRule .*                              /custom_theme/images/%1 [L]
| 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.