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'm quite new to apache so any help is appreciated! I've got Apache and tomcat (through mod_jk) running on my desktop. I defined all static files (i.e HTML) to be served by apache and all jsp to be forwarded to tomcat

I can access all jsp and html files directly without a problem. For example:

  1. localhost/sb/jsp/index.html - works
  2. localhost/sb/jsp/dates.jsp - works

I'm trying to rewrite all URLs so wouldn't need to go through sb/jsp. Meaning:

  1. localhost/index.html rewrite to localhost/sb/jsp/index.html
  2. localhost/dates.jsp rewrite to localhost/sb/jsp/dates.jsp

Pretty simple right?

The problem is that mod_rewrite works great for html but not for jsp. I can even see in the log that the rewrite is enforced for the jsp file but I still get a 404: - - [31/Jul/2010:22:01:04 +0300] [localhost/sid#9154d0][rid#927ce0/initial] (2) init rewrite engine with requested uri /dates.jsp - - [31/Jul/2010:22:01:04 +0300] [localhost/sid#9154d0][rid#927ce0/initial] (3) applying pattern '/dates.jsp' to uri '/dates.jsp' - - [31/Jul/2010:22:01:04 +0300] [localhost/sid#9154d0][rid#927ce0/initial] (2) rewrite '/dates.jsp' -> '/sb/jsp/dates.jsp' - - [31/Jul/2010:22:01:04 +0300] [localhost/sid#9154d0][rid#927ce0/initial] (2) local path result: /sb/jsp/dates.jsp - - [31/Jul/2010:22:01:04 +0300] [localhost/sid#9154d0][rid#927ce0/initial] (1) go-ahead with C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/sb/jsp/dates.jsp [OK]

Does any one have any idea why this happens? Pasted below is the mod_jk.conf where I configured everything.

########## Auto generated on Sat Jul 31 20:46:04 IDT 2010##########

<IfModule !mod_jk.c>
LoadModule jk_module "modules/mod_jk.so"

<VirtualHost localhost>
ServerName localhost
# Options +FollowSymLinks
RewriteLogLevel 9
RewriteLog "C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/rewrite.log"
RewriteEngine on
RewriteRule /index.html /sb/jsp/index.html
RewriteRule /dates.jsp /sb/jsp/dates.jsp

# JkMount / ajp13
JkMount /*.jsp ajp13
DocumentRoot "C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps"

JkMount /manager ajp13
JkMount /manager/* ajp13

# JkMount /sb ajp13
# JkMount /sb/* ajp13

JkMount /docs ajp13
JkMount /docs/* ajp13

JkMount /examples ajp13
JkMount /examples/* ajp13

JkMount /host-manager ajp13
JkMount /host-manager/* ajp13
share|improve this question
add comment

1 Answer

Check that mod_rewrite is loaded before mod_jk so that mod_rewrite will handle requests before mod_jk.

share|improve this answer
Not sure how that's done? also, is that viable in Apache 2.2? I thought this was an older version feature –  user50004 Aug 3 '10 at 17:57
Look through your apache config file and any file it includes. You should find LoadModule rewrite_module modules/mod_rewrite.so somewhere. That needs to come before the position where mod_jk.conf in Included. This is a feature of all apache version. –  Mark Wagner Aug 3 '10 at 21:36
add comment

Your Answer


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