Custom url rewriting

[answer updated as wanted]

It’s better to hook your function to generate_rewrite_rules so you won’t have fall into infinite loops and flushing rewrite rule on every request. So you can do this:

function add_my_rules($wp_rewrite) 
{
    $new_rules = array(
        '^cityprofile/\?city=(Sydeny|Melbourne|Brisbane)$' => $wp_rewrite->preg_index(1) // for 3 cities
    );
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'add_my_rules');

and then regenerate structure by going to Permalinks structure section and doing an update.

Note that this will redirect http://domain.com/cityprofile/?city=Sydneyto http://domain.com/Sydney but if you mean redirection from second URL to the first one I should say that it’s not possible because it doesn’t have somthing particular and clear in url to write a specefic pattern and will effect all other urls as well.

So my suggestion:

You can make your url more structural and understandable by adding a rewrite rule for http://domain.com/city/Sydney that opens up http://domain.com/cityprofile/?city=Sydeny

Update #2

Replace this rules with previous ones in .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(Sydney|Melbourne|Brisbane)$ cityprofile/?city=$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress