Answer the question
In order to leave comments, you need to log in
How does the [QSA] flag in mod_rewrite work?
Is it written somewhere in the official docs that the [QSA] flag itself adds an aspersand (&) to the existing parameters? I know that it seems to be adding, and if we prepare a string for the parameters from {query_string} in the second argument of RewriteRule by manually writing '&', we will get a double ampersand, but it's not written anywhere about it, it's just written that the query parameters are stored there, however not a word about the ampersand.
And the second question I encountered:
Everywhere they write that "If the [QSA] flag was specified, the query parameters will be added to the beginning of % {QUERY_STRING}."
But with the request " site.ru/news/?id=4 " and the rule " RewriteRule ^news/$ index.php/?type=news [QSA]", we see that it seems like parameters (id=4) are added to the end of %{QUERY_STRING} (type=news), and the final query_string is equal to "type=news&id=4". So are they added to the beginning or to the end? Or under % {QUERY_STRING} here we mean exactly the user's parameters, and "parameters" are those that are written in the second argument of RewriteRule:
Answer the question
In order to leave comments, you need to log in
you did not take into account the fact that this is a GET and it is not part of the url and therefore does not fall into your condition.
# 301 --- site.ru/news/?id=4 => site.ru/index.php/?type=nes
RewriteCond %{QUERY_STRING} (^|&)id\=4($|&)
RewriteRule ^news/$ /index.php/?type=nes [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question