how rewrite is working in wordpress

You can best analyse the URL rewrites with the URL Rewrite Analyser which has been developed by Jan Fabry, see the following answer for more information.

Furthermore you can change the structure of the permalinks under the Options –> Permalinks of the WordPress admin section.