Apache 2.4.41 on Ubuntu 16.04.5 LTS. From what I gather from the docs, the use of the END flag should prevent sub requests but it does not - at least not when used in conjunction with the P flag. It seems that the issue only happens when requesting existing directories (/, /existing_dir, /dir/existing_sub_dir), it does not happen for file requests. As a workaround, the undesired behaviour can be fixed by disabling the DirectoryIndex. Here is the rewrite rule: RewriteRule (.*) http://127.0.0.1:3000/test?q=$1 [P,END] Here is the debug (trace5) log sample: [Fri Oct 18 20:30:16.179651 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] strip per-dir prefix: /var/www/html/test1/website/public/ -> [Fri Oct 18 20:30:16.179688 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] applying pattern '(.*)' to uri '' [Fri Oct 18 20:30:16.179694 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] rewrite '' -> 'http://127.0.0.1:3000/test?q=' [Fri Oct 18 20:30:16.179699 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] split uri=http://127.0.0.1:3000/test?q= -> uri=http://127.0.0.1:3000/test, args=q= [Fri Oct 18 20:30:16.179703 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] escaped URI in per-dir context for proxy, http://127.0.0.1:3000/test -> http://127.0.0.1:3000/test [Fri Oct 18 20:30:16.179706 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] forcing proxy-throughput with http://127.0.0.1:3000/test [Fri Oct 18 20:30:16.179710 2019] [rewrite:trace1] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir /var/www/html/test1/website/public/] go-ahead with proxy request proxy:http://127.0.0.1:3000/test?q= [OK] [Fri Oct 18 20:30:16.179756 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] strip per-dir prefix: /var/www/html/test1/website/public/index.html -> index.html [Fri Oct 18 20:30:16.179760 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] applying pattern '(.*)' to uri 'index.html' [Fri Oct 18 20:30:16.179768 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] rewrite 'index.html' -> 'http://127.0.0.1:3000/test?q=index.html' [Fri Oct 18 20:30:16.179771 2019] [rewrite:trace3] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] split uri=http://127.0.0.1:3000/test?q=index.html -> uri=http://127.0.0.1:3000/test, args=q=index.html [Fri Oct 18 20:30:16.179774 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] escaped URI in per-dir context for proxy, http://127.0.0.1:3000/test -> http://127.0.0.1:3000/test [Fri Oct 18 20:30:16.179777 2019] [rewrite:trace2] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] forcing proxy-throughput with http://127.0.0.1:3000/test [Fri Oct 18 20:30:16.179787 2019] [rewrite:trace1] [pid 17308:tid 140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - - [test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir /var/www/html/test1/website/public/] go-ahead with proxy request proxy:http://127.0.0.1:3000/test?q=index.html [OK]
Also, using the (NS|nosubreq) flag somehow prevents the proxy request from being sent. This happens only when internal sub-requests follow the initial request. The log shows "go-ahead with proxy request proxy:http://127.0.0.1:3000/test?q= [OK]" but the httpd never issues a request to the proxied application.
Probably related to https://bz.apache.org/bugzilla/show_bug.cgi?id=56434