Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Given a URL:

http://example.com/some-file.zip

The document root for example.com is /var/www/example.com/

I want apache to:

1) If /var/www/example.com/some-file.zip exists, serve it.
2) If /var/www/example.com/some-file.zip doesn't exist, 
   check /var/www/shared/some-file.zip
3) If /var/www/shared/some-file.zip doesn't exist, send a 404

Is this possible?

I've looked in to the Alias directive, but I think this will require me to have something in the URI indicating where the resource is.

share|improve this question
1  
This would be pretty trivial with nginx's try_files. Ever considered switching? –  Michael Hampton Jun 2 '13 at 20:50
    
Thanks Michael, you just convinced me to switch. Do you have any links regarding the triviality of a setup like this? –  jessh Jun 3 '13 at 0:06

2 Answers 2

up vote 1 down vote accepted

For files outside the DocumentRoot, check out the aptly named documentation section on "Files Outside the DocumentRoot" -- you're looking at creating an Alias, and you may be able to do it without a redirect.

share|improve this answer
    
I think this is on the right track.. but it will require me to have some indicator of the resource in the URI.. e.g. I can't just alias "/" –  jessh Jun 3 '13 at 0:34
RewriteCond %{DOCUMENT_ROOT}$1 !-f
RewriteRule (.*) /var/www/shared$1 [last]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.