title: Forcing tomcat to use www.domain.com instead of domain.com
body: <p>At the moment I'm using Apache's mod_rewrite to redirect all html requests to http(s)://www.domain.com/blah instead of http(s)://domain.com/blah.</p>
  
  <p>Everything works fine except when I connect to tomcat at domain.com:8080. All I've done is naively put the same .htaccess file into my /opt/tomcat-7/webapps/ROOT directory, but it doesn't seem to work.</p>
  
  <p>I'm actually hoping I'm way off track with what I've tried above and there is a way I can always rewrite domain.com:8080 to www.domain.com:8080 without having to place a new .htaccess file into every webapp directory, but if not, what am I doing wrong in the above?</p>
  
  <p>I've searched all over Google for others having just this problem with tomcat to no avail.</p>
  
  <p>For the record, my .htaccess file is:</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} !^$
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTPS}s ^on(s)|
  RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>Cheers,
  Ben.</p>