3

I'm having a similar problem to the one described on this question. However, I managed to get nginx (1.0.14) compiled with the latest PCRE (8.30), changed the rewrite rule to use UTF8, but it still fails.

My rewrite rule is

location / {
    try_files $uri $uri/ /index.php;
    rewrite "(*UTF8)^/imgthumb/(.*)$" /timthumb.php?$1 last;
}

This works fine with images without unicode, but fails when the filename contains unicode characters.

so /imgthumb/src=/wp-content/uploads/8姉妹の古いマトリョーシカ.jpg&h=121&w=137&zc=1 fails

but /imgthumb/src=/wp-content/uploads/MOD0005.jpg&h=121&w=137&zc=1 works fine.

On Apache using .htaccess rewrite rule, it works with both

RewriteRule ^/imgthumb/(.*)$ /timthumb.php?$1 [L]

Is my nginx rewrite rule wrong? Is there a way to make this work?

UPDATE: I noticed that the problem seems to stem from the fact that the PHP script gets only one parameter (src) into the $_GET array with nginx, but with apache rewrite it's broken down to different parameters...

Community
  • 1
  • 1
gingerlime
  • 5,206
  • 4
  • 37
  • 66

1 Answers1

3

The solution was eventually provided by Valentin V. Bartenev on the nginx forum after I posted the same question there.

Replacing the rewrite rule with this snippet made this work!!

   location ~ (*UTF8)^/imgthumb/(.*)$ {
            fastcgi_pass    unix:/var/spool/phpfpm.sock;
            include         fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME    $document_root/timthumb.php;
            fastcgi_param   SCRIPT_NAME        /timthumb.php;
            fastcgi_param   QUERY_STRING $1;
    }
gingerlime
  • 5,206
  • 4
  • 37
  • 66
  • 1
    I'd add an important thing: if you don't put (*UTF8) in location regexp, and you put that in your rewrite regexps inside, will *NOT* work. That could help. – StormByte Feb 21 '13 at 21:07