problem with PCRE matching, utf-8, Greek, rewrite

tmanolat nginx-forum at nginx.us
Thu Sep 23 13:12:53 MSD 2010


initially this worked well: (\x{386}-\x{3ff} for Greek chars)
[code]
		location ~ "^(/optionalwebappname)?/ProcessImageServlet.*$" {
				root   /opt/myfilerepository/;
				rewrite ^(.+)$ http://static-dev.myhost.eu/$arg_hotel_id/$th$fn
break;

			set $hid '';
			set $filename '';
			set $th '';
			
			if ($request_uri ~ "^(.*)[\\?|&]hotel_id=([0-9]+)(&.*)?$") {
				set $hid $2;
			}
			if ($request_uri ~ "(*UTF8)^(.*)[\\?|&]filename=([%
,a-zA-Z0-9\x{386}-\x{3ff}_\-\.]+)(&.*)?$") {
				set $fn $2;
			}
			if ($request_uri ~ "^(.*)[\\?|&]type=th(&.*)?$") {
				set $th 'th_';
			}
			rewrite ^(.+)$ http://static-dev.myhost.eu/$hid/$th$fn break;
			access_log  logs/site-pis.log  main;
			expires           1h;
		}

[/code]


however, later I found this to work better, including of course utf8
arguments - you would better check this out first... much more elegant

[code]
                location ~
"^(/optionalwebappname)?/ProcessImageServlet.*$" {
			set $th '';
			
			if ($request_uri ~ "^(.*)[\\?|&]type=th(&.*)?$") {
				set $th 'th_';
			}
			rewrite ^(.+)$
http://static-dev.myhost.eu/$arg_hotel_id/$th$arg_filename break;
			expires           1d;
		}
[/code]

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,104357,133276#msg-133276




More information about the nginx mailing list