Something very similar can be done using Apache's mod_rewrite more traditional rules. Or as you've noted in the conversation to @Zak's answer perhaps using an internal redirect.
Here is an example sequence:
- User visits page (e.g.
http://myhost.com/my_area/my_file.jpg)
.htaccess is configured to pass all requests for /myarea (or even /) to a php script. (e.g. handle-url.php) (Example code)
- The logic in
handle-url.php can now do any of several things:
- Return an error
- Redirect the user to any url using the the
header("Location: URL) method as mentioned by @Zak (e.g. http://myhost.com/file_area/my_file.jpg )
- Directly read the file from disk and return the data to the user. (Example code)
Take a look at the mod_rewrite's advanced example page. Depending on what exactly you need to do there may be other options.
For example, On-the-fly Content-Regeneration may be helpful. As may FallbackResource.