I have a strange problem with mod_rewrite, the rules that are relevant here are:
RewriteRule ^(.*)\/igre\-(.*)\.php\?Page=([0-9]+)$ game.php?GameUrl=$2&Page=$3 [L] RewriteRule ^(.*)\/igre\-(.*)\.php$ game.php?GameUrl=$2&Page=1 [L]
And a corresponding URL might look something like this:
example.com/miselne-igre/igre-shirk.php?Page=2 example.com/miselne-igre/igre-shirk.php
The problem is that the first rule has no effect. If I use the first URL from the example I always get 1 into the Page variable, which shows that the second rule is used. So what’s wrong with the first one? And why is the second rule even matching a URL with ‘.php?Page=XYZ’ at the end, if I said that the URL ends with ‘.php’?
ps: other rules in the .htaccess file are working fine…
The query string is not part of the URI path that is being processed by the
RewriteRuledirective. You have to use theRewriteConddirective to process the query string.But you can still simplify this by using the QSA flag (query string append):