http://codex.wordpress.org/Template_Hierarchy
The General Idea
WordPress uses the Query String — information contained within each link on your web site — to decide which template or set of templates will be used to display the page.
To see the query string put this in your theme’s page template:
<?php
echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>";
?>
WordPress matches every Query String to query types — i.e. it decides what type of page (a search page, a category page, the home page etc.) is being requested.
Templates are then chosen — and web page content is generated — in the order suggested by the WordPress Template hierarchy, depending upon what templates are available in a particular WordPress Theme. Read More