Rewrite error rule with unicode urls to nginx with pcre 8.3
I ran into a similar problem to the one described in 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 doesn't work.
My rewrite rule
location / {
try_files $uri $uri/ /index.php;
rewrite "(*UTF8)^/imgthumb/(.*)$" /timthumb.php?$1 last;
}
This works fine with non-unicode images, but fails when the file name contains unicode characters.
therefore /imgthumb/src=/wp-content/uploads/8姉妹の古いマトリョーシカ.jpg&h=121&w=137&zc=1
does not work
but it /imgthumb/src=/wp-content/uploads/MOD0005.jpg&h=121&w=137&zc=1
works .
In Apache using the htaccess rewrite rule, it works like
RewriteRule ^/imgthumb/(.*)$ /timthumb.php?$1 [L]
Am I rewriting the nginx rule correctly? Is there a way to make this work?
UPDATE: I noticed that the problem seems to be related to the fact that the PHP script only gets one parameter (src) into an array $_GET
with nginx, but with Apache transition, it splits into different parameters ...
source to share
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 did the job!
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;
}
source to share