Forum Moderators: phranque

Message Too Old, No Replies

tomcat directory & mod rewrite

         

thu household

4:11 am on Aug 21, 2006 (gmt 0)

10+ Year Member



I am using mod_jk2 to tunnel requests sent to a particular folder from apache to tomcat (I am using workers.properites file). Now I am trying to add mod_rewrite to support dynamic user defined domains. The request for different subdomains will go to a jsp page as a parameter. (direct acess to www.example.com/tomcatDir/xyz.jsp is working fine - i.e. it goes to tomcat but after url rewrite it does not go to tomcat. My URL rewrite works if the directory is just in the apache (but then my jsp page does not get executed). I have tried loading mod_jk2 after loading mod_rewrite & also tried the [PT] instead of [L] in the rewrite rule below

Here I have given my workers.properties snippet & my httpd.conf configuration for url rewrite..

workers.properties:

[uri:www.example.com/tomcatDir/*]
worker=ajp13:localhost:8009

[uri:www.example.com/tomcatDir]
worker=ajp13:localhost:8009

[uri:example.com/tomcatDir/*]
worker=ajp13:localhost:8009

[uri:example.com/tomcatDir]
worker=ajp13:localhost:8009

httpd.conf

<VirtualHost --ip-address-->
DocumentRoot "F:\apache2\htdocs\example\"
ServerName www.example.com
ServerAlias *.example.com
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST}!www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z][a-z0-9_\-]{2,11})\.example\.com
# Rewrite subdomain as a parameter to jsp page
RewriteRule ^/(.*)$ /tomcatDir/xyz.jsp?url=%2&landingPage=$1 [L]
</VirtualHost>

jdMorgan

12:55 pm on Aug 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> loading mod_jk2 after loading mod_rewrite

If you review the documentation, you'll find that Apache modules are executed in the reverse order that they are loaded. Therefore, you'll want to load mod_jk before mod_rewrite so that it runs later, and try that along with [PT].

If that doesn't work, you may want to replace the mod_jk/mod_proxy functions with the [P] (proxy-pass-through) function available in mod_rewrite.

Jim

thu household

3:42 pm on Aug 21, 2006 (gmt 0)

10+ Year Member



Sequence change for the load module did not work for me. It seems in apache 2.2 there is mod_proxy_ajp module and that might help..But I need to apache upgrade for that..need to that in the night. Will update tomorrow then..In the mean time if any other suggestion with apache 2.0.54 then please let me know..

thu household

7:22 am on Aug 22, 2006 (gmt 0)

10+ Year Member



Again, thanks for your help. With proxy_mod_ajp it works fine. Only thing i could not figure out is how to get query parameters if my url is
[subdomain.example.com...]
then i am able to retrieve sudomain & testpage.jsp but not?id=5&category=9
(i will have to have generic solution as in the subdomains there can be many types of jsp pages each taking different types of query parameters)

jdMorgan

12:14 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you wish to preserve the requested query string, and append the "url=%2&landingPage=$1" stuff to it, then you'll need to add the [QSA] flag (Query String Append) on the RewriteRule.

Jim

thu household

4:39 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



qsa worked good..thanks a lot..