The Doc says: „REQUEST_URI“ “The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as its own variable named QUERY_STRING.“ https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond This not correct. I have tried and the %{QUERY_STRING} is a part of %{REQUEST_URI} (not only in rewrite-rules, in PHP $_SERVER['QUERY_STRING'] show the same. Per Definitionem is the query a part of the uri (URI). so shold only the documentation be corrected. Discussion (in german): https://forum.selfhtml.org/self/2022/may/30/weiterleitung-von-domain-zu-domain/1799519#m1799519
In my testing the query string is not part of the %{REQUEST_URI} variable resolved by mod_rewrite (or expression-based use) The REQUEST_URI environment variable passed to CGI and CGI-like handlers has a different value, the one you'd expect based on the name (including the query) If you think it really contradicts the doc in mod_rewrite in some config please share the most basic config that demonstrates the issue and the resulting rewrite:trace8 and access_log.
Created attachment 38307 [details] error.log .filtered The error.log shows explicit: applying pattern '(.*)' to uri '/' rewrite '/' -> 'https://home.fastix.org/' explicitly forcing redirect with https://home.fastix.org/ escaping https://home.fastix.org/ for redirect copying foo=bar to query string for redirect redirect to https://home.fastix.org/?foo=bar [REDIRECT/301]
Created attachment 38308 [details] This show the redirect of the client-side.
Created attachment 38309 [details] The config file for the apache
on fastix.de i have only this in a .htaccess - File. This has the same effect: The query (try fastix.org/test?foo=bar) is in the redirect-uri: RewriteEngine On RewriteRule (.*) https://www.fastix.org%{REQUEST_URI}
Sorry, there is an error in my descryption: on fastix.de i have only this in a .htaccess - File. This has the same effect: The query (try fastix.de/test?foo=bar) is in the redirect-uri: RewriteEngine On RewriteRule (.*) https://www.fastix.org%{REQUEST_URI} --- chanched „try fastix.org/test?foo=bar“ to „try fastix.de/test?foo=bar“
The query-string is used because the target URI is a full URI (starting with "https:") and mod_rewrite preserves the query-string for full URIs. If you want to avoid that, use the [QSD] flag (instead of [QSA]).
> „The query-string is used because the target URI is a full URI“ I think this should also be noted in the documentation in this case. Because the statement "This notably excludes the query string" conveys that the query is never part of '%{REQUEST_URI}'.
(In reply to Jörg Reinholz from comment #8) > the statement "This notably excludes the query string" conveys that the > query is never part of '%{REQUEST_URI}'. It's actually true that the query-string is never part of %{REQUEST_URI} in mod_rewrite, the query string generated by your redirect rule comes from the rule itself, not the content of the %{REQUEST_URI} variable. Nevertheless, it probably should be included in the docs (though not relative to %{REQUEST_URI}).
Note added in r1901487.