title: Why is query string repeated in rewrite URL?
body: <p>I have these rewrites. The first (for gallery) works as expected. The second (for photo) works but the query string is repeated. So it forwards to: <a href="http://www.domain.com/photo-TheID?id=TheID" rel="nofollow">http://www.domain.com/photo-TheID?id=TheID</a></p>
  
  <pre><code>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /gallery\.php\?set=([^/]*)\ HTTP/
  RewriteRule ^gallery\.php$ http://www.domain.com/gallery?set=%1 [R=301,L]
  
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /photo\.php\?id=([^/]*)\ HTTP/
  RewriteRule ^photo\.php$ http://www.domain.com/photo-%1 [R=301,L]
  </code></pre>
  
  <p>However, if I add ? to the end of the rewriterule making it</p>
  
  <pre><code>RewriteRule ^photo\.php$ http://www.domain.com/photo-%1? [R=301,L]
  </code></pre>
  
  <p>It then works as expected forwarding to: <a href="http://www.domain.com/photo-TheID" rel="nofollow">http://www.domain.com/photo-TheID</a></p>
  
  <p>My question is why is that query string being repeated without the "?" at the end? It's very confusing to me since the first rewrite (for gallery) does not have the ? yet it does not repeat the query string. If I add ? to the end of the gallery rewriterule it adds "%3f" to the end of the url.</p>