Apache has an incredible option called “MultiView.” If you have a file named ‘file.php’ and you have a rewrite rule to rewrite ‘/file/image.jpeg’, MultiView will look at the requested URI ‘/file/image.jpeg’, see that there is no directory ‘/file/’, then it will see if there is a file named ‘file.php’. It will then send the request to that file instead of honoring your original request.
I ran into this problem because I’m using VirtualHostX to write my <VirtualHost> definitions, and it adds ‘MultiViews’ automatically. This has the effect of appending a ‘.php’ to the end of a directory. You can read about it here (scroll down to the MultiView part).
The fix is actually simple. Either remove ‘MultiView’ from the <VirtualHost> definition (inside a <Directory> rule), or you can add the following line to your .htaccess file: ‘Options Indexes FollowSymLinks’
I hope this helps someone, someday.