I had a unique requirement to show a block on the page only if the page url has arguments, after much of research I found out the following method to customize the block.

  1. In admin->structure blocks restrict your block for the required page
  2. In your custom module implement hook_block_list_alter()
  3. Unset the block content if argument does not match
/** 
 * Implements hook_block_list_alter().
 */
function mymodule_list_alter(&$blocks) {
  foreach($blocks as $key => $block) {
    if ($block->module == 'custom_block'){
      if (!isset($_GET['parmeter'])) {
        unset($blocks[$key]);
      }
    }
  }
}

Hope this helps.