title: redirect url with query string to path, and url without query string must be internally rewritten
body: <p>I've been trying and trying.</p>
  
  <p>If one goes to:<br/></p>
  
  <pre><code>www.domain.nl/vereniging
  </code></pre>
  
  <p><strong>internally</strong> a page is requested from:<br/></p>
  
  <pre><code>www.domain.nl/?p=vereniging
  </code></pre>
  
  <p>For that I use this:<br/></p>
  
  <pre><code>RewriteCond %{QUERY_STRING} !(p=.*)$
  RewriteRule ^(.+)$ ?p=$1 [NC]
  </code></pre>
  
  <p><br/>
  If a users visits:<br/></p>
  
  <pre><code>www.domain.nl/?p=vereniging
  </code></pre>
  
  <p>I want the users to be redirected to:<br/></p>
  
  <pre><code>www.domain.nl/vereniging
  </code></pre>
  
  <p>For that I use:<br/></p>
  
  <pre><code>RewriteCond %{QUERY_STRING} ^p=(.*)$    [NC]
  RewriteRule ^$ http://www.domain.nl/%1?     [NC,R=301]
  </code></pre>
  
  <p>(If I put <em>RewriteCond %{REQUEST_FILENAME} !-d</em> before this, it doesn't redirect anymore. That's strange because a query is not a directory right?)</p>
  
  <p>Separately, these 2 chunks of code work.</p>
  
  <p>However, if I put them together in 1 .htaccess it bitches about looping.<br/>I don't understand this, because the conditions should prevent looping.</p>