1

While working on an application rewrite, I'd like to keep the old app webroot files as a fallback, when the new files are not found.

There are 2 applications:

<VirtualHost *:80>
    ServerName legacy.dev
    DocumentRoot /www/legacy/webroot
</VirtualHost>
<VirtualHost *:80>
    ServerName new.dev
    DocumentRoot /www/new/webroot
</VirtualHost>

How could I setup the new.dev VirtualHost to retrieve the files present in the DocumentRoot, but if the file is not found, retrieve the files in the legacy.dev DocumentRoot?

user365877
  • 113
  • 3

1 Answers1

0

It sounds like What is Apache's equivalent of Nginx's try_files? would do what you want.

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ balancer://app_cluster%{REQUEST_URI} [P,QSA,L]

tries to look for the file and if it doesn't find it passes it to the apache proxy. Apache: mod-rewrite to look up missing images in another directory shows a similar example of using mod_rewrite to do something similar without the proxying. As you can see it uses a similar RewriteCond but a rather different RewriteRule which may be easier to work with.

As you may note the first referenced answer is trying to hack nginx's try-files into apache so maybe you'd be happier with nginx directly in this case. How does try_files work? should give you a better idea if that would help you.

chicks
  • 3,793
  • 10
  • 27
  • 36