RewriteCond %{QUERY_STRING} (.*)\?mem=stats$
RewriteRule ^/(.*)$ http://X.X.X.X/$1?%1 [P,L]
If the request is /asdf?mem=stats
, will it rewrite to /asdf?mem=stats?asdf
?
since $1
is asdf?mem=stats
and %1
is asdf
???
The %{QUERY_STRING}
variable contains the query string without the leading ?
(or anything before it), so %1
will never contain part of the request before query string.
If you enable mod_rewrite logging by adding LogLevel rewrite:trace6
to your VirtualHost configuration, you will see this for your RewriteCond and /asdf?mem=stats
request:
... RewriteCond: input='mem=stats' pattern='(.*)\\?mem=stats$' => not-matched
Also, in your RewriteRule
, pattern will be matched against the part of the URL after the hostname and port, and before the query string. Therefore $1
will, even on wildcard match, not contain the query string part of the request. You can see that in log as:
... applying pattern '^/(.*)$' to uri '/asdf'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.