.htaccess文件到nginx迁移

Here are apache rewrite rules

RewriteCond %{REQUEST_URI} index.php$

RewriteCond %{QUERY_STRING} ^search=([A-Za-z0-9+]+)$

RewriteRule ^(.*)$ /mp3-%1.html? [R=301,L]

RewriteRule ^mp3-([^+]+)+([^.]+).html$ /mp3-$1-$2.html [R=301,L]

RewriteRule ^mp3-(.*).html$ index.php?search=$1&a=1 [L]

RewriteRule ^mp3-([a-zA-Z0-9_-]+)-([^-]*).htm$ /index.php?search=$1&page=$2 [L]

I tried all converter websites to convert it from .htaccess to nginx configuration. Some of them come out with following result

if ($http_host ~* "^domain.com"){
    set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
    rewrite /(.*) http://www.mp3ecevir.net/$1 permanent;
}
if ($uri ~ "index.php$"){
    set $rule_1 1$rule_1;
}
if ($args ~ "^search=([A-Za-z0-9+]+)$"){
    set $rule_1 2$rule_1;
    set $bref_1 $1;
}
if ($rule_1 = "21"){
    rewrite ^/(.*)$ /mp3-$bref_1.html? permanent;
}
    rewrite ^/mp3-([^+]+)+([^.]+).html$ /mp3-$1-$2.html permanent;
    rewrite ^/mp3-(.*).html$ /index.php?search=$1&a=1 last;
    rewrite ^/mp3-([a-zA-Z0-9_-]+)-([^-]*).htm$ /index.php?search=$1&page=$2 last;

But it doesn't rewrite properyly? What am I doing wrong?

By the way

Here is my htaccess file: http://pastebin.com/KfvK2SNK

And here is nginx: http://pastebin.com/uSH5trfG