Tuesday, September 13, 2016

mod_rewrite does not rewrite jsp files

I've set up everything and mod_rewrite works properly on HTML files but not on jsp files.



I'm getting the following message in my rewrite log:



(2) init rewrite engine with requested uri /index.jsp applying pattern '^/([\w\d]*).jsp$' to uri '/index.jsp'

(2) rewrite '/index.jsp' -> '/sb/jsp/index.jsp'
(2) forcing '/sb/jsp/index.jsp' to get passed through to next API URI-to-filename handler



I've set up mod_jk and I can access /sb/jsp/index.jsp with no issue. I would like to have users access /index.jsp and then be rewritten to /sb/jsp/index.jsp.



My rewrite rule (notice I use the PT flag to force mod_rewrite to forward to mod_jk):



RewriteRule ^/([\w\d]*).jsp$ /sb/jsp/$1.jsp [PT] [NC] [QSA] [L]



Anyone has any idea what's going on? seems like the request is being forwarded but never gets to mod_jk.




Another thing I just noticed. If I take the PT flag out I get a different message in the log:
(1) go-ahead with /sb/jsp/index.jsp [OK]
And the /index.jsp instead of /sb/jsp/index.jsp
So seems like apache is forwarding to tomcat but not the rewritten URL...



Thanks!

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...