I need a nginx rewrite rule to rewrite from:

`http://some-keyword.example.com` to `www.example.com/keyword.php?keyword=$some-keyword`

while domain without `www` in front still rewrites to `www.example.com` and `www` isn't taken as a keyword.

Please could you help me to solve this problem, how to write these two rules?