DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Find Files In Previous Folders With Mod_rewrite
It recursively goes up in the directories structure until it finds the requested file name or fails with status 404
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]*/(.*) $1
Assuming the file "/test/x.txt" exists, when requesting the url "/test/blabla/folder/xyz/x.txt", it will go up until finding the requested file: /test/blabla/folder/x.txt /test/blabla/x.txt /test/x.txt (found...)





