View Single Post
  #1 (permalink)  
Old December 5th, 2005, 12:34 PM
fanch fanch is offline
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default mod_jk + apache + mod_rewrite

Hi there,

I have managed to get apache and tomcat working together fine except for one thing in the mod_rewrite.

here is my mod_rewrite bi in http.conf
[...]
RewriteEngine on

RewriteRule "^/file(.*)$" "/dir/servlet/file$1" [R,L]
RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRule "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]
[...]

that works fine. Except that the URL is redirected (R flag) which I don't wan't.
If I use
RewriteRule "^/file(.*)$" "/dir/servlet/file$1" [L]
alone it works fine but if I use it with the HTTPS redirect then the URL rewriting is visible to the user

http://server.domain/file.whatever?key=value

becomes

https://server.domain/dir/servlet/fi...ever?key=value

It would like it to be
https://server.domain/file.whatever?key=value

I have tried to change my rewriting rules to
RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRule "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]
RewriteRule "^/file(.*)$" "/dir/servlet/file$1" [PT,L]

but no matter wich way I turn it mod_jk doesn't take it. (Apache return a 403 error on the file name). I have to use the R flag to make it work.

As I said earlier
RewriteRule "^/file(.*)$" "/dir/servlet/file$1" [L]
works fine and the URLs
http://server.domain/file.whatever?key=value
are handled by tomcat.

I don't what I am missing out and doing wrong....

Hope this makes sense.
Any suggestions or pointer is mostly appreciated.

Regards
Fanch