I'm pretty sure the issue is that %{REQUEST_FILENAME}
does not reference a URI as it as been changed, but instead as it has been requested.
I have some code like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule app/?(.*)$ /some-site/map-app/$1 [NC,QSA]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule some-site/map-app/?(.*)$ /some-site/map-app/index.html [NC,L,QSA]
</IfModule>
The effect is supposed to be that
/app
goes to ->/some-site/map-app
when searching for files- if that fails (as it will often because it's an SPA), it goes to
/some-site/map-app/index.html
For some reason it's rewriting every path to the index.html
fallback. This means that #1 is occurring enough to meet the RewriteRule
condition, but for some reason the RewriteCond
are not working.
If I remove the logic for #2, the files resolve fine so the issue is not that the paths it produces are bad.
I've read the docs on "RewriteCond Specials" (https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html)
Why are these two not failing for paths that exist -- and have been produced by the first logic block -- within the second logic block?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Some examples and the desired outcome:
/app/
->/some-site/map-app/index.html
/app/map/id-3
->/some-site/map-app/index.html
/app/app.js
->/some-site/map-app/app.js
/app/assets/img/1.png
->/some-site/assets/img/1.png
(RewriteEngine logic not included in post, but example included in case it changes potential answers)