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: http://www.domain.com/photo-TheID?id=TheID
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]
However, if I add ? to the end of the rewriterule making it
RewriteRule ^photo\.php$ http://www.domain.com/photo-%1? [R=301,L]
It then works as expected forwarding to: http://www.domain.com/photo-TheID
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.