Can I mod rewrite to a different document root?
Given a URL:
http://example.com/some-file.zip
The document root for example.com
is /var/www/example.com/
I want apache to:
- If
/var/www/example.com/some-file.zip
exists, serve it. - If
/var/www/example.com/some-file.zip
doesn't exist, check/var/www/shared/some-file.zip
- 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.
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.
RewriteCond %{DOCUMENT_ROOT}$1 !-f
RewriteRule (.*) /var/www/shared$1 [last]