Custom rewrite rules with pagination in wordpress

Sometimes we need to use $_GET params in custom pages for something like custom filter.
In my case i must create page with custom query_posts, filter this posts and glossary. In glossary links must look like or

First we need to create page with slug 'glossary' and set permalink to Post name.
In theme directory copy page.php to page-glossary.php and put this code