Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

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

This question came from our site for professional programmers interested in conceptual questions about software development.

    
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

2 Answers 2

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).

share|improve this answer
    
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

If I understand your issue correctly, you want to turn "abc.com" into "www.abc.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://abc.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.abc.com/index.html.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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