Need help with rewrite rule

Igor Sysoev is at rambler-co.ru
Wed Feb 25 10:18:25 MSK 2009


On Tue, Feb 24, 2009 at 07:15:09PM -0800, Chris Cortese wrote:

> In Apache, I use the following rule.  It runs the combinator script, 
> which serializes, minimizes, and gzips a list of javascript files:
> 
> RewriteRule ^/javascript/(.*\.js) /combine.php?type=javascript&files=$1
> 
> In nginx, I've tried many things, to no avail.  Right now I have:
> 
> rewrite ^/javascript/(.*\.js)$ /combine.php?type=javascript&files=$1 last;
> 
> When I load my page and expand the HTML in firebug, at the place where I 
> have:
> 
> <script type="text/javascript" 
> src="http://mysite.com/javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js"></script>
> 
> ...it shows me 1 line as follows:
> 
> effects.js,builder.js,lightbox_live.js,box.js
> 
> 
> Surely wildcards in nginx are greedy right?  Can anybody see what's 
> wrong here?

nginx uses PCRE regex library:

$pcretest 
PCRE version 7.6 2008-01-28

  re> #^/javascript/(.*\.js)$#
data> /javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js
 0: /javascript/prototype.js,effects.js,builder.js,lightbox_live.js,box.js
 1: prototype.js,effects.js,builder.js,lightbox_live.js,box.js
data> ^D

BTW, I do not think that "the combinator script, which serializes,
minimizes, and gzips a list of javascript files" is a good thing.

It's much better to combine them statically.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list