I am using mod_jk for my web application and apache is configured to serve every content via Tomcat other than the static css, images and js.

I want the URL without www (abc.com) to redirect to with www subdomains (www.abc.com)

I tried escaping .htaccess via mod_jk unmount statement but .htaccess doesn't seem to work in this case.

I think the basic issue is that apache is not responding to any .htaccess rule. If I can Apache make respond to .htacess the problem should be in control.

Any idea how this can be done?

Here is my .conf for the domain

JkMount /* worker1

JkUnMount /css/* worker1

JkUnMount /images/* worker1

JkUnMount /js/* worker1

JkUnMount /.htaccess worker1

migrated from programmers.stackexchange.com May 21 '12 at 11:27

This question came from our site for professionals, academics, and students working within the systems development life cycle.

  • sounds like you want to bypass tomcat for abc.com and have apache redirect the user to www.abc.com - is this correct? – ztron May 21 '12 at 17:40
  • That was correct, but I made it work via htaccess redirect. the issue was the same web root directory for apache and tomcat and a erroneous conf file. – Ashish Kaushik Jun 4 '12 at 21:20

If I understand your issue correctly, you want to turn "example.com" into "www.example.com" via a redirect. Apache httpd ought to do this for you if you use this configuration option:

UseCanonicalName On

Note that this is the default.

I have this configuration on my server and if I hit http://example.com/index.html (obviously an example: don't consider the previous a live link), I get a 301 (Moved Permanently) response sending me to http://www.example.com/index.html.


You need to see apache's RewriteRule config option to do any redirects. As far as I remember, you can't do via Tomcat configuration (and you shouldn't, mod_rewrite is much much richer).

  • I was not able to do and I didn't even tried via tomcat. It worked via htacess after I corrected my webroot directories for apache and tomcat. – Ashish Kaushik Jun 4 '12 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.