Help with url rewrite

The PHP code is not enough, you need to edit your .htaccess file correspondingly. (You can do this with $wp_rewrite->mod_rewrite_rules(); somehow, or edit it manually.) However, be aware that URL rewriting is complicated stuff – are you sure you need it? If you are using pretty permalinks for posts/pages, chances are this will bork it up.