What no one has pointed out to you is that, as per the docs, RewriteCond
s accept backreferences to the matched pattern in the RewriteRule
. So where you are currently testing that the request is not a regular file you would instead check your preferred substitution is a file. Repeat this for your fallback substitution.
Edit: the RewriteCond
s in your comment don’t make sense, the first part should be the subject of the test, the second part the test. You put the backreferences to the rule in the subject. Obviously, you’ve had a go, try this:
RewriteCond /pub/$1/snapshots/$0 -f
RewriteRule ^(ffmpeg|ffprobe|ffserver|ffplay)-[0-9]+-g[0-9a-z]+\.(?:7z|dmg)$ /pub/$1/snapshots/$0 [END]
RewriteCond /pub/archive/$0 -f
RewriteRule ^(?:ffmpeg|ffprobe|ffserver|ffplay)-[0-9]+-g[0-9a-z]+\.(?:7z|dmg)$ /pub/archive/$0 [END]
9
solved how to use rewrite, if first rewrite doesn’t yield a result (search in different locations)