title: Why won't my RewriteRules play nice together?
body: <p>The first part of my code works and redirects/rewrites to <code>new/file</code>. Problem occurs when I try to pass variables. They all get redirected to <code>new/file</code></p>
  
  <p>Whatever variable I try to pass in <code>file.php?foo=bar</code> redirects to <code>new/file</code> instead of <code>new/file/bar</code>.  </p>
  
  <p>for example:  </p>
  
  <ul>
  <li>new/file rewrites to file.php </li>
  <li>new/file/2 rewrites to file.php?page=2</li>
  <li>file.php redirects to new/file</li>
  <li>file.php?page=2 doesn't redirect to new/file/2 but get's overwritten to new/file instead</li>
  </ul>
  
  <p>My code: </p>
  
  <pre><code>RewriteBase /domain.com
  
  #regular 
  RewriteCond %{QUERY_STRING} !redirect=no
  RewriteRule ^file\.php$ new/file? [NS,R=301,L]
  RewriteRule ^new/file?$ file.php?redirect=no [NS]
  
  #with variable
  RewriteCond %{QUERY_STRING} ^page=([0-9-]+)/?$ 
  RewriteRule ^file\.php$ new/file/%1?  [NS,R=301,L] 
  RewriteRule ^new/file/([0-9-]+)/?$ file.php?page=$1&amp;redirect=no [NS]
  </code></pre>
  
  <p>Please note that I am passing more than just <code>page</code> variables.</p>
  
  <p>I'm thinking maybe a <strong>QSA flag</strong> is supposed to go somewhere?</p>