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.
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.
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 http://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?
I’ve searched all over Google for others having just this problem with tomcat to no avail.
For the record, my .htaccess file is:
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]
Cheers,
Ben.
Tomcat doesn’t do anything with .htaccess files: that’s an Apache httpd thing.
You have a couple of options, here: