[development] Rewrite rules and file access

Lee Rowlands rowlands at rowlands1.dnsalias.org
Wed Jul 14 09:58:31 UTC 2010


Hi
I asked this one on the list during Drupalcon SF but got no response
(the list was quiet that week!) so here goes again:

*The Background*
---------------
I've got a module I'm working on that needs to force some images to go
via the private download method.
This is working fine rerouting links via system/files in combination
with a htaccess file limiting direct access to the directory.
I also need thumbnails in various sizes of the images so it makes sense
to use imagecache.
I want the site in public download method except for these files and
I've successfully got the imagecache integration working.
I've used hook_menu_alter to prevent people accessing the relevant
imagecache file path directly, rerouting the imagecache cached images
via system/files.
The problem is, once the imagecache file is created, the file is no
longer being served via Drupal, with Apache serving it direct. This
obviously does not get near my access callback.

*The Questions*
---------------
Is this down to Drupal's rewrite rules? 
Are the rewrite rules not evaluated if the file actually exists?
Can I create a rewrite rule to force this file to go through Drupal -
the relevant files all contain a common element in their path so I
should be able to match it) or do I need to consider alternatives such
as creating .htaccess files in the subfolders for each imagecache
preset, monitoring for new presets?

Any suggestions welcome.
Lee Rowlands




More information about the development mailing list