Forum Moderators: phranque

Message Too Old, No Replies

Unable to rewrite url for tomcat using Apache

         

cool_jack

3:46 pm on Jun 8, 2008 (gmt 0)

10+ Year Member



Hi,

I have setup mod_jk so that it sent the requests to a particular folder from apache to tomcat(it is working fine). Following is what I have setup in my httpdconfig file;

  # Mod_jk settings
#

JkWorkersFile "conf/workers.properties"
JkLogFile "logs/mod_jk.log"
JkLogLevel info
JkMount /GeekMantra default
JkMount /GeekMantra/* default

# End of mod_jk settings

So whenever I type

http://localhost/GeekMantra
it send request to tomcat and jsp files are parsed by tomcat.

Now I am trying add rewrite rules for dynamic urls using mod_rewrite and following is what I have setup in httpdconfig file.


<VirtualHost localhost:8080>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
ServerName localhost
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common

Options +FollowSymLinks
RewriteEngine on
Options +FollowSymLinks
RewriteEngine on
RewriteRule GeekMantra/subsection/(.*)/(.*)/(.*)/(.*)/$ /GeekMantra/subsection?$1=$2&$3=$4 [PT]
</VirtualHost>

My Dynamic url look like this,

http://localhost/GeekMantra/subsection?section=JSP&subSection=first

After rewrite it comes in this form,

http://localhost/GeekMantra/subsection/section/JSP/subSection/first/

But the rewrite is not working it is showing

HTTP Status 404 - /GeekMantra/subsection/section/JSP/subSection/first/ 

I really can't able to figure out why rewrite rule is not able to be implemented in this way or Am I missing some thing?.

A help in this would highly appreciated.

Thanks.
Mahavir.

jdMorgan

4:49 pm on Jun 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is possible that your server is configured such that mod_JK gets control and passes the request to your Tomcat back-end before mod_rewrite can be applied. In Apache 1.x, modules are executed in the reverse order that they appear in the LoadModule list. Therefore, mod_rewrite must be placed *after* mod_JK in your LoadModule list; otherwise, it will never get control and your rules will not be executed.

In Apache 2.x, module execution order is controlled by an "internal priority scheme" and that is the only description I know of, so I can't give you nay more information than that... :(

Jim

cool_jack

5:15 pm on Jun 8, 2008 (gmt 0)

10+ Year Member



Thanks for your reply but I am using Apache 2.0.63. Thanks anyway for you kind reply...will try to figure out..but I did what all I can do.