Greeting Apache experts, I have an interesting question that has perplexed me all day regarding custom error responses, the environment variables they create, and rewrite rules.
I'm using Apache 1.3 working with Tomcat to serve JSP pages.
For the error document directive I have the following entry in my conf file:
ErrorDocument 404 /pageNotFound404.jsp
According to the documentation (
http://httpd.apache.org/docs/1.3/custom-error.html ) Apache should be making some environment variables prefixed with "REDIRECT_". Specifically I'm looking for the REDIRECT_URL and REDIRECT_QUERY_STRING variables.
I know getting Apache's environment variables into Tomcat isn't a very safe thing to do (and not possible in the environment I'm working on) so I'm trying to handle it via mod_rewrite. Unfortunately the "REDIRECT_" vars don't seem to be populated at that stage in the request's lifespan. Here is the rewrite rule I'm using:
RewriteCond %{REQUEST_URI} pageNotFound404.jsp
RewriteRule ^(.*)$ /pageNotFound404.jsp?R_URL
=%{REDIREC
T_URL}&R_Q
UERY_STRIN
G=%{REDIRE
CT_QUERY_S
TRING} [QSA]
The rule is being processed as I'm getting empty (not null) values for the parameters. When I look at the QueryString value from the ServletRequest object I get the following:
QueryString: R_URL=&R_QUERY_STRING=
Can anyone give any insight on how to reference these environment variables and/or when they are populated? I'm not able to use an intermediate cgi script to harvest and forward to the .jsp page so it all needs to be done within this scope.
Thanks!
Start Free Trial