I seem to have a problem whereby mod_rewrite is sending multiple requests back to my Lucee server. Sometimes 2 requests, sometimes 4 requests. I have a special application framework in Lucee to handle and manage all requests. It requires the request to be rewritten and proxied back to Lucee as "/" (root) with a request parameter set to the user requested URI. All of the rewriting appears to work properly but more than one request gets fired by the backend server. The following is my rewrite rule setup:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ "/" [E=vPath:$1,PT,NE,NS,L]
<If "-T reqenv('vPath')">
RequestHeader add "vPath" "%{vPath}e"
</If>
The RewriteRule simply grabs the URI and sets the environment variable "vPath", then rewrites the URI to "/" with the parameters:
PT (pass through to next handler)
NE (no URI escaping of output)
NS (not for internal sub-requests)
L (last rule)
This all seems to work just as needed, however, in testing I have verified that the request hitting the code behind in Lucee is actually getting called multiple times. If I turn RewriteEngine off
, then only a single request is sent to the backend. Turn RewriteEngine on
and multiple requests are again sent (anywhere from 2 to 6).
Also note that it doesn't seem to matter if I use "P" (force proxy) or "PT" (pass through to next handler), I get the same multiple request results.
Any help would be greatly appreciated. I am somewhat of a NUBE to mod_rewrite.
System:
OS: Linux 4.18.0-11-generic
Java: 1.8.0_181
Lucee: 5.2.9.31
Apache Tomcat: 8.5.33