I've got an odd problem. Apache is replying with a 400 error code instead of 404 when ever a client requests a non existing jsp page (html request are answered correctly with a 404). The only time Apache serves correctly with a 404 is when the request to the non existent page is to a file in the root directory. I'm aware that the root directory matches a rewrite rule but still it doesn't seem relevant.
For example:
www.xxx.com/jjj.jsp - 404
www.xxx.com/bla/jjj.jsp - 400
I've got Apache 2.2 and Tomcat 6 install with mod_jk. I forward all jsp requests to mod_jk. Here's my relevant httpd.conf input:
ServerAdmin [email protected]
DocumentRoot /opt/tomcat/webapps/sb
ServerName xxx
ErrorLog /var/log/httpd/xxx/error_log
CustomLog /var/log/httpd/xxx/custom_logs common
JkMount /*.jsp ajp13
RewriteEngine On
RewriteLogLevel 9
RewriteLog /var/log/httpd/xxx/rewrite.log
RewriteCond %{HTTP_HOST} !^www\.xxx\.com$ [NC]
RewriteRule ^(.*)$ http://www.xxx.com$1 [R=301,L]
RewriteRule ^/([\w\d]*).jsp$ /sb/jsp/$1.jsp [PT,NC,QSA,L]
RewriteRule ^/$ /sb/jsp/index.jsp [PT] [NC] [QSA] [L]
Here is an output from custom_logs
x.x.x.x - - [08/Dec/2010:09:34:40 -0500] "GET /examples/ddd.jsp HTTP/1.1" 400
x.x.x.x - - [08/Dec/2010:09:59:59 -0500] "GET /gti.jsp HTTP/1.0" 200 662
The error is coming from tomcat. Hit tomcat directly.
Also the rewrite rules for
RewriteRule ^/([\w\d]*).jsp$ /sb/jsp/$1.jsp [PT,NC,QSA,L]
is catching root level jsps. That is - any jsp in the top level directory. So when there is a /gfoo.jsp is run - it is rewritten to /sb/jsp/foo.jsp - otherwise it is not rewritten.