Issue
My question is similar to this one, but with an important distinction. I want to be able to serve a file in case a lookup fails in the main DocumentRoot, not depending on the path of the file.
On my Apache server, I want to be able to have multiple DocumentRoot directives for my websites. This way, if it fails to find the file in the main DocumentRoot folder, it can look in another (common) folder. Here's what I mean:
<VirtualHost *:80>
DocumentRoot /var/www/example/html
# insert additional document root here
# DocumentRootAlias /var/www/common/html
ServerName www.example.com
ServerAlias example.co
</VirtualHost>
I already have the global DocumentRoot setup as /var/www/common/html, but I don't know how to make a VirtualHost look in here if it fails in it's current DocumentRoot.
Again, I'd like the server to look in the common folder if it fails to find something in the .../example/html folder.
Does Apache support this?
Solution
Converting comment to answer:
At the end of all rewrite rules, put this:
RewriteCond %{REQUEST_FLENAME} !-f
RewriteRule ^ /var/www/common/html%{REQUEST_URI} [L]
Answered By - hjpotter92 Answer Checked By - Senaida (WPSolving Volunteer)