Can't get ImageCache working

jchatard - July 2, 2008 - 13:09
Project:Multisite Manager
Version:5.x-1.0-1
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi, I'm using Virtualsite_manager, which works pretty well. For files attachments as well.

But I still can't get ImageCache 2.1 to called, Drupal always sends me a 404 not found from menu_execute_active_handler() on this test:

if ($path === '' || !isset($menu['callbacks'][$path])) {
   return MENU_NOT_FOUND;
}

I'm using the .htaccess following rules :

RewriteEngine on

#file access
RewriteRule ^\w+/(modules|misc|files|themes|sites)(.*)$ ./$1$2 [L]
RewriteRule ^/(modules|misc|files|themes|sites)(.*)$ ./$1$2 [L]

#special php scripts
RewriteRule ^\w+/(update.php|install.php|index.php|cron.php)(.*)$ ./$1$2 [L,QSA]

#site sub-section
RewriteCond %{REQUEST_FILENAME} ^/Applications/MAMP/htdocs/dotc/site/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\w+(/)?(.*)$ index.php?q=$2 [L,QSA]

I gave a try by deleting 'files' from RewriteRule like this:

RewriteRule ^\w+/(modules|misc|themes|sites)(.*)$ ./$1$2 [L]
RewriteRule ^/(modules|misc|themes|sites)(.*)$ ./$1$2 [L]

This leads ImageCache to work properly, but attachements don't work anymore.

I'm not a Apache rewriting rules expert at all, but I guess I can fix the issue with a rule excluding only 'files//imagecache', but I don't know how to achieve this.

Help would be much appreciated!

Thank you all,
Jérémy

#1

jchatard - July 2, 2008 - 13:31

Just correcting a typo in my previous comment:

I'm not a Apache rewriting rules expert at all, but I guess I can fix the issue with a rule excluding only 'files/site_shortname/imagecache', but I don't know how to achieve this.

#2

jchatard - July 2, 2008 - 13:38

Just a quick note, when disabling URL aliases, all works fine!

Jérémy

#3

schuyler1d - July 2, 2008 - 15:45

I'm not a Apache rewriting rules expert at all
get ready, my guess is by the end of this, you will be :-/

Just a quick note, when disabling URL aliases, all works fine!
in drupal? you mean clean urls or something else?

I don't have time atm to do testing on my side, but a shot in the dark would be something like this:

RewriteEngine on

#file access
RewriteRule ^\w+/(modules|misc|themes|sites)(.*)$ ./$1$2 [L]
RewriteRule ^/(modules|misc|themes|sites)(.*)$ ./$1$2 [L]

#NEW STUFF
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/(files)(.*)$ ./$1$2 [L]

RewriteCond %{REQUEST_URI} ^\w+/(files.*)$
RewriteCond %1 -f
RewriteRule ^\w+/(files)(.*)$ ./$1$2 [L]

#special php scripts
RewriteRule ^\w+/(update.php|install.php|index.php|cron.php)(.*)$ ./$1$2 [L,QSA]

#site sub-section
RewriteCond %{REQUEST_FILENAME} ^/Applications/MAMP/htdocs/dotc/site/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\w+(/)?(.*)$ index.php?q=$2 [L,QSA]

The trickiest part is that imagecache is specifically relying on the request being passed to drupal if and only if a file does not exist.

If you figure this out (or if the above magically worked), please post what you did here, so I can commit it back into the project! Otherwise I might have some time later this week or next.

#4

jchatard - July 2, 2008 - 22:12

Wouah thanks a lot, I'll give it a try tomorrow morning (midnight in France), and I'll let you know if it works!

In the mean time thank you!

Jérémy

#5

jchatard - July 3, 2008 - 08:31

Ok so it works great, appart for one thing. Now images are well generated, thank you!

But when I edit a node, the imagefield preview, which points to the original image, doesn't show and leads to a 404 not found page.

I guess a simple rule could let access files directly?
Jérémy

#6

schuyler1d - July 3, 2008 - 13:02

what's the url of the imagefield preview image, and can you see these images from the view mode of the same node? It's possible this part is a bug in imagefield/imagecache instead.

#7

jchatard - July 4, 2008 - 07:35

Well I don't think this is a bug due to Imgafield nor ImageCache, cause Drupal also generate a 404 for attached files as well! I'm using public method.

Seems like rewrite rules prevent from accessing files under "files/" directory.

#8

jchatard - July 10, 2008 - 11:48
Status:active» closed

You where right, this an issue due to imagefield. Many people seem to have the same. So I'll work on that.
Thanks

#9

schuyler1d - July 31, 2008 - 14:30
Status:closed» needs review

keeping this open for the patch to the rewrite rules. thanks for reporting

 
 

Drupal is a registered trademark of Dries Buytaert.