title: .htaccess mod rewrite to redirect query string to a path
body: <p>I've recently updated my website to use:</p>
  
  <pre><code>www.website.com/path/123456
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>www.website.com/path/file.php?id=123456
  </code></pre>
  
  <p>In order to not break legacy links/bookmarks, I'd like to redirect the old query strings to the new paths.</p>
  
  <p>I've tried:</p>
  
  <pre><code>RewriteRule ^path/file.php?id=?$ /path/$1 [L,R]
  </code></pre>
  
  <hr>
  
  <pre><code>RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ [NC]
  RewriteRule ^path/.* /path/$1 [R]
  </code></pre>
  
  <hr>
  
  <pre><code>RewriteCond %{REQUEST_URI} ^/path/$ [NC]
  RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ [NC]
  RewriteRule .* /path/$1 [R]
  </code></pre>
  
  <hr>
  
  <pre><code>RewriteCond %{REQUEST_URI} ^/path/file.php$ [NC]
  RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ [NC]
  RewriteRule .* /path/$1 [R]
  </code></pre>
  
  <p>and a few variations, but with no luck. How do I need to set up my .htaccess to perform this redirect?</p>