I can't for the life of me fathom out why this RewriteCond is causing every request to be sent to my FastCGI application when it should in fact be letting Apache serve up the static resources.
I've added a hello.txt
file to my DocumentRoot to demonstrate.
The text file:
ls /Sites/CioccolataTest.webapp/Contents/Resources/static
hello.txt
The VirtualHost and it's rewrite rules:
AppClass /Sites/CioccolataTest.webapp/Contents/MacOS/CioccolataTest -port 5065
FastCgiExternalServer /Sites/CioccolataTest.webapp/Contents/MacOS/CioccolataTest.fcgi -host 127.0.0.1:5065
<VirtualHost *:80>
ServerName cioccolata-test.webdev
DocumentRoot /Sites/CioccolataTest.webapp/Contents/Resources/static
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /Sites/CioccolataTest.webapp/Contents/MacOS/CioccolataTest.fcgi/$1 [QSA,L]
</VirtualHost>
Even with the -f, Apache is directing requests for this text file (i.e. access http://cioccolata-test.webdev/hello.txt returns my app, not the text file).
As a proof of concept I changed the RewriteCond to:
RewriteCond %{REQUEST_URI} !^/hello.txt
That made it serve the text file correctly and allowed every other request to hit the FastCGI application.
Why doesn't my original version work? I need to tell apache to serve every file in the DocumentRoot as a static resource, but if the file doesn't exist it should rewrite the request to my FastCGI application.
NOTE: The running FastCGI application is at /Sites/CioccolataTest.webapp/Contents/MacOS/CioccolataTest
(without the .fcgi prefix)... the .fcgi prefix is only being used to tell the fastcgi module to direct the request to the app.