I'm using Apache 2.4 with mod_jk and Tomcat running a Java servlet. The application I'm serving has an ugly index URL: accessing www.mydomain.com/ takes the user to www.mydomain.com/view/user/www/. I would like to alias this so that users see www.mydomain.com/app/ instead, and I'm trying to use mod_rewrite to achieve this. This is the current setup I have:
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
JkWorkersFile /etc/apache2/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # Is it one of these options?
VirtualHost *:80>
ServerName www.mydomain.com
Redirect permanent / https:/www.mydomain.com
</VirtualHost>
<VirtualHost *:443>
ServerName www.mydomain.com
ServerAdmin webmaster@localhost
JkMount / tomcat
JkMount /* tomcat
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule ^/$ /app [PT]
RewriteRule ^/app/?$ /view/user/www [PT,L]
RewriteRule ^/app/(.*)$ /view/user/www/$1 [PT,L]
SSLEngine on
SSLCertificateFile /path/to/my_domain.crt
SSLCertificateKeyFile /path/to/my_domain.key
SSLCertificateChainFile /path/to/chainfile.crt
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
All of this is in apache2.conf. It's currently doing something different to what I would like. When you type in www.mydomain.com/app, the address in the bar changes to www.mydomain.com/view/user/www (and it serves the correct page). I want the bar to continue to display www.mydomain.com/app but display what tomcat has at /view/user/www, thus hiding the ugly URL from the user. How can I achieve this?
RewriteRule ... [PT]
+ mod_jk requires
JkOptions +ForwardURICompatUnparsed