Hi,
I have a Tomcat (6.0.20) and Apache Server setup (2.2) and am trying to redirect all subdomains to a specific context, on my domain.
e.g., s.example.com redirect to www.example.com
Apache is fowarding requests via mod_jk
(I tried mod_proxy
, but the css and js didn't load as its not absolute urls).
My current setup:
httpd.conf:
Include C:/apache-tomcat-6.0.20/conf/auto/mod_jk.conf
RewriteEngine On
<VirtualHost *:80>
ServerName www.example.co.za
ServerAlias www.example.co.za example.co.za *.example.co.za
RewriteEngine on
RewriteLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/rewrite.log"
RewriteLogLevel 3
RewriteCond %{HTTP_HOST} example\.co\.za.*$ [NC]
RewriteRule ^(.*)$ http://www.example.co.za [L]
JkMount /* worker1
</VirtualHost>
JkMount /* worker1
server.xml:
<Host name="www.example.co.za" appBase="hosts/example"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="C:/apache-tomcat-6.0.20/logs" prefix="localhost_access_log."
suffix=".txt" pattern="common" resolveHosts="false"/>
<Context path="" docBase="Property"/>
<Alias>*.example.co.za</Alias>
</Host>
The redirect for ww.example.com is going into a non-stop redirect loop.
This is extremely important from a security point of view as the user could access the tomcat manager and other apps on the server (namely hudson).