Forum Moderators: phranque
Jim
Jim and others do a marvelous job here and all as volunteers (without compensation).
Thus. . .show your best effort and ask for comments and assistance from that effort.
That malformed "something.htmlabcd" URL is NOT this mod_rewrite rule's doing...
With the rule I posted above,
RewriteRule ^games/(.+)\.html$ games/game.php?games=$1 [QSA,L] a request for
example.com/games/whack-a-mole.html
gets passed to your script as
example.com/games/game.php?games=whack-a-mole
and a request for
example.com/games/whack-a-mole.html?level=3
gets passed to your script as
example.com/games/game.php?level=3&games=whack-a-mole
If anything else is happening, then the problem is likely either another rewriterule interfering with this one, or the game.php script itself. The reason I can say that is that neither your original rule nor this new one can "change the URL" because both of them are internal rewrites. Neither of them communicates in any way with the browser, and so cannot change the URL in the browser's address bar.
In order to change the address in the browser's address bar, an external redirect is required (as opposed to this internal rewrite). So this indicates that another mechanism is coming into play, and generating an external redirect response to the browser.
When reporting problems, please include both the code (if changed) and the URL you used to test. Also, please be sure that your example URLs remain consistent. Otherwise, debugging even trivial code such as this will become a chore.
Jim
In the absence of a new query string and [QSA], mod_rewrite passes query strings through rewrites unchanged by default.
Also note that RewriteRule cannot 'see' query strings appended to requested URL-paths, as they are data *attached to a URL* to be passed to the resource *at* that URL. For this reason, you must use a RewriteCond to examine %{QUERY_STRING} if you wish to match and back-reference query strings. However, that's not necessary in this case, as using [QSA] seems entirely sufficient.
Oh, and to make it official -- Welcome to WebmasterWorld!
Jim