I seem to have fixed it by rearranging the rules as: 1. File exists without Directory rule (used to be the default handler), Final 2. Redirect rule for non-existent files 3. Change default rule to HTTP error (404)
Do "File exists" rules not work when combined via AND with "Directory" rules? On Sat, Feb 11, 2012 at 9:08 PM, Daniel Lo Nigro <[email protected]> wrote: > Hi everyone, > I'm trying to move one of my sites from Apache to Cherokee. I've nearly > got it working but I'm stuck on one of the rewrite rules. The directory > js/combined has a .htaccess file containing: > > ExpiresActive on > ExpiresDefault "access plus 1 month" > > RewriteEngine on > > # Rewrite non-existent URLs to the combiner, to create a new combined file > RewriteCond %{REQUEST_FILENAME} !-f > RewriteCond %{REQUEST_FILENAME} !-d > RewriteRule (\d+).js combine.php?set=site&v=$1 [L] > > I use this for "lazy JavaScript minification". Basically, when a user hits > /js/combined/123.js and 123.js doesn't exist yet, it goes through the > combine.php script. The combine.php script combines and minifies all the > JavaScript files used by the site, outputs them to the correct file name > (123.js) and then serves the file itself. After this is done, every user > gets the file directly (as it now exists). I've got a deployment script > that deploys the site and increments the "version number" used in the JS > URLs. it seems to be working quite well on Apache. > > However, on Cherokee I can't get it working. I've tried the following > rules: > 1. Extension php - FastCGI, Non-final, cache turned off > 2. Directory /js/combined AND File Exists - List & Send, gzip, IO cache > turned off (for debugging), Final > 3. Directory /js/combined - Rewrite, Final > - Internal, (\d+).js$ to /js/combined/combine.php?set=site&v=$1 > > In theory the "file exists" rule should serve the existing files, as it's > marked as "final". However this isn't happening and every request is going > through the combine.php script. > > I've tried the following rules with the same result: > 1. Extension php - FastCGI, Non-final, cache turned off > 2. Directory /js/combined AND NOT File Exists - Rewrite, Final, IO cache > turned off (for debugging) > - Internal, (\d+).js$ to /js/combined/combine.php?set=site&v=$1 > 3. Directory /js/combined - List & Send, gzip, Final > > In this case, every file still seems to be going through the combine.php > script as well!? In either scenario, turning off the rewrite serves > existing files correctly, but obviously non-existent URLs don't work. > > tl,dr: I want to rewrite a URL in a directory only when the file doesn't > exist, but am having issues with that. > > Any suggestions? > > -- > Regards, > Daniel Lo Nigro > http://dan.cx/ | http://twitter.com/Daniel15 >
_______________________________________________ Cherokee mailing list [email protected] http://lists.octality.com/listinfo/cherokee
