I have moved all files from a project that should be accessible from outside to a single public directory – so that instead of blacklisting directories that must remain hidden, I could whitelist accessible ones.
However I cannot force apache to rewrite this kind of urls:
to fetch
<DOCUMENT ROOT>/public/images/flower.jpg
Only rational solution I came up with was something among those lines:
RewriteCond public\/%{REQUEST_FILENAME} -f #if a file exists in the public dir,...
RewriteRule .* public/$0 [L] #display it
Unsurprisingly, it does not work, more precisely, the RewriteCond part, I can’t get it to match.
I am completely at loss, could someone help?
As a side question, how do you debug .htaccess configurations? I can’t fix the problem if I don’t know what and where it is.
If you want to test for an existing file with
-f, you need to provide an absolute file system path like this:Otherwise use
-Fto do the check via a subrequest: