Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 xxx@xxx.com
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
share|improve this question
The 400 errors are probably coming from tomcat, not from Apache (since you're proxying them to tomcat via ajp). Is there anything in your tomcat logs? –  larsks Dec 8 '10 at 17:58
the error is coming from tomcat: –  user58052 Dec 9 '10 at 13:39

1 Answer 1

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.