Search code examples
apachemod-rewriteglassfishmod-jk

jk_mod and apache rewrite


Is it possible to combine rewrite rules with jk_mod with server side forward?

I have a simple configuration

RewriteEngine On
RewriteRule ^/$ /myapp [R]

JkMount /* worker_1

This works great when using the redirect flag but fails to run without it. What I want to achieve is a server side forward so the user's browser bar doesn't notice the rewrite.

Thank you.


Solution

  • Give a try to mod_proxy_http, You need to enable mod_proxy and mod_proxy_http:

    LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
    LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
    

    Then in your VirtualHost section:

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass /css !
    ProxyPass /img !
    ProxyPass /js !
    ProxyPass / http://localhost:8080/myapp/
    ProxyPassReverse / http://localhost:8080/myapp/
    

    Note: the ProxyPass /xxx ! are not needed from your question. I just wanted to show how to exclude some URI from being 'translated'