Naneau just poke me with a little problem he had with mod_rewrite when trying to rewrite to a subdirectory. Imagine you've got the following setup:
- Apache's document root is /document_root/
- You application's bootstrap is /document_root/public/index.php
You could come to the following rewrite rules quite easily:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php/$1 [L]
And you'd be horribly wrong.
The problem here is that when you hit / on your server, mod_rewrite will populate %{REQUEST_FILENAME} it to /document_root/, which obviously fails the !-d rewrite condition. By the magic of DirectoryIndex, you'll eventually hit /index.html (or whatever your directory index is set to), and there we go for another rewrite magic. At this point, things get a little messy, and if you're like naneau, you'll end up crying while rolling on the floor and calling for help on irc (that's quite a set of hard things to achieve at the same time).
The solution is not that simple, and actually, I've not found a fully satisfying solution yet (although naneau is satisfied with the partial solution). The quick hack is to simpy remove the !-d condition. The obvious drawback is that any existing directory will get rewritten, but you'll be able to access the files inside it. I'm still working on a more complete solution, but as it's not my main concerne for the moment, it'll wait a bit (unless someone posts a solution in the comments).