I was in a situation in which I wanted to test for the existence of a file as a condition in a rewrite (see the end of this thread for background). I wanted to be able to write:
rewrite {
r (.*)
if_op or
if {file} ends_with .php
if {path}/index.php exists
to /proxyphp/{1}
}
I have read various threads which show how to get around this by using the “to” parameter with multiple paths, but none of these were able to do what I actually wanted in this instance.
Depending on how the parsing of parameters works and what would be easiest, an alternative syntax might be:
So if I’m understanding this right, where a multi-destination rewrite goes to the file you’re testing for, you want to rewrite to a different destination than the file you’re testing for.
Hmm, that’s an interesting conundrum. I’ll think on it, but my initial thought is that you’re right, it can’t be done at present, and I can’t think of any tricky way to get around it to proxy any indexes with PHP files like fastcgi does out of the box with the php preset.
One point of interest is that testing for file/directory existence is noted as an optional todo on this work-in-progress PR: