[development] Rewrite rules and file access

Ken Winters kwinters at coalmarch.com
Wed Jul 14 12:17:48 UTC 2010

I had the same issue at one point.  I think the end solution was  
writing a new callback
(so it didn't map directly to a file), setting up a perm check on it,  
and on success returning
what imagecache would have.  Then I denied direct access to the  
imagecache path.

- Ken Winters

On Jul 14, 2010, at 5:58 AM, Lee Rowlands wrote:

> 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