title: Drupal: hook_url_inbound_alter in url_rewrite: rewrite query part of URL for paging
body: <p>I'm trying to use url_rewrite to work around nonfriendly parameters in URL of <code>paging</code> module. I wish to turn URLs like <code>page-title.html?page=0,1</code> to <code>page-title/page1.html</code>.</p>
  
  <p>Here are my hooks:</p>
  
  <pre><code>function mymod_url_outbound_alter(&amp;$path, &amp;$options, $original_path) {
      $localPath = $path . '?' . $options['query'];
      dpm("_url_outbound_alter($localPath)");
      if (preg_match('|(.+)\.html\?page=0%2C(\d+)|', $localPath, $matches)) {
          $path = "${matches[1]}/page${matches[2]}.html";
          unset($options['query']);
          dpm("altering path to $path");
      }
  }
  
  function mymod_url_inbound_alter(&amp;$result, $path, $path_language) {
      if (preg_match('|(.+)/page(\d+)\.html|', $path, $matches)) {
          //$result = "${matches[1]}.html?page=0,${matches[2]}";
          $result = "${matches[1]}.html";
          //$_GET['q'] = "page=0,${matches[2]}";
          $_GET['page'] = "0,${matches[2]}";
          dpm("altering in-path to $result");
      }
  }
  
  function mymod_boot() {}
  </code></pre>
  
  <p>Is it impossible to add query part in hook_url_inbound_alter? </p>
  
  <ul>
  <li>If I comment out
  mymod_url_outbound_alter, it works,
  bot comma us URL-encoded - OK, it did show the friendly URL.</li>
  <li>If I enable both, the
  page goes into infinite redirect 301
  loop. </li>
  <li>The commented out variants also
  don't seem to work.</li>
  </ul>
  
  <p>Yes, I know it's better to fix <code>paging</code> to use non-query URL. But the module is a little too complex to do that reliably. <code>pagination</code> module lacks features for me.</p>
  
  <p>Is the problem in URL altering? What can I do to make it work?</p>