I am having difficulty defining a correct RewriteRule to forward requests to an application running in tomcat. I have apache with mod_rewrite enabled as well as tomcat setup with an application mounted with mod_jk. Without a virtual host, I can browse to the following url without issue. (context being the application running in tomcat)
http://www.domain.com/context
How do I configure the RewriteRule to pass requests from domain.com to the application running in tomcat.
http://www.domain.com --> http://www.domain.com/context
Here is what my current virtual host file looks like
<VirtualHost *:80>
ServerName www.domain.com
<Directory />
Options FollowSymLinks
AllowOverride None
RewriteEngine On
RewriteRule \/$ /context [L]
</Directory>
<Directory /var/www/html/context/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
This will pass the request from domain.com
to a directory named context
in /var/www/html
. How do I override the default apache setup to pass the request to the application running in tomcat?
Thanks in advance for your help.
Something like this, where localhost:8080 is where your tomcat server is running.
I edited my virtual host file. I added the JkMount inside the virtual host file instead of 000-default.conf and was able to get apache to pass the request to the tomcat application instead of the folder in apaches web directory. I also now have 2 virtual host files, one for the main domain and the other for the domain without www. prefix. Here is what they look like :
www_domain.conf
domain.conf