重写URL的Glype(nginx)

I've a Glype proxy and I want to rewrite the URL's. All URLs on the page are automatically converted to: http://proxy.com/browse.php?u=[URL HERE]. Example: If I go to /browse on The Pirate Bay on my proxy I want to convert the URL from this:

proxy.com/tpb/browse.php?u=http%3A%2F%2Fthepiratebay.se%2Fbrowse&b=0

To this:

proxy.com/tpb/browse

As you can see, the whole part:

browse.php?u=http%3A%2F%2Fthepiratebay.se%2F

Is gone (and the &b=0 what is behind the URL). And it has the same domain structure as The Pirate Bay .

I've tried something like this:

        location /tpb/ {
        rewrite ^/browse.php?u=(.*)$ /$1? last;
        break;
            }

But it is not working. Somebody has an answer? An other function is also welcome. (Such as fastcgi_split_path_info or something else what is compatible with nginx)

(If you want see a example go to tpb.piratenpartij.nl but I'm not sure if they are using Glype)

I think that proxy.com/tpb/browse.php?u=http%3A%2F%2Fthepiratebay.se%2Fbrowse&b=0 would match location /tpb/browse.php, so you can write

location /tpb/browse.php {
    rewrite ^/tpb/browse\.php.* $host/tpb/browse redirect;
}

Hope it does what you wanted, it does not care about ?u=, do you really need it?

Let me know if it works, I have nowhere to try it right now.