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 have two domains foo.org and bar.org.

All traffic to foo.org (including all sub domains) goes to foo.org

All traffic to bar.org also (one exception) goes to foo.org (eg: abc.bar.org should redirect to foo.org)

A sub-domain tools.bar.org which should point to a different directory.

I have the following virtual host configuration:


<VirtualHost *:80>
ServerName tools.bar.org
ServerAlias tools.bar.org

DocumentRoot /opt/bitnami/apps/tools/htdocs/


<VirtualHost *:80>
ServerName foo.bar
ServerAlias *.foo.org, bar.org, *.bar.org

DocumentRoot /opt/bitnami/apps/foo/htdocs/

RewriteEngine On

RewriteCond %{HTTP_HOST} ^bar\.org [NC]
RewriteRule ^/$ http://foo.org [L,R=301]
RewriteCond %{HTTP_HOST} ^www.bar\.org [NC]
RewriteRule ^/$ http://foo.org [L,R=301]


The problem is if I enable tools.bar.conf tools.bar.org points correctly, but www.foo.org which should be pointing to foo.org now points to tools.bar.org . foo.org works properly as earlier.

In browser this is what I see:

tools.bar.org points to what is expected.

abc.bar.org is redirected to foo.org. the address in browser address bar also changes to foo.org. (expected)

xyz.foo.org also is redirected to foo.org (expected)

www.foo.ord is redirected to (tools.bar.org) (not expected).

I am clueless on how to solve this.

share|improve this question
What's your question? –  slm Jan 7 '13 at 4:34
slm-- there was a formatting mistake because of which the question part did not get posted, updated the question. Please check –  rAm Jan 7 '13 at 7:36
According to your (obfuscated) configuration you use foo.bar, not foo.org. Obfuscation will make troubleshooting domain-name-related issues very hard. If you absolutely must obfuscate the domain names, at least keep the obfuscation consistent. Also describe how exactly www.foo.org doesn't "point correctly", i.e. what do you get when you enter that address in a browser? What do your Apache logs say about such requests? –  Ansgar Wiechers Jan 7 '13 at 8:10
Ansgar- Sorry for the incomplete question,I now updated the question to my best of abilities, please let me know if more details are needed. –  rAm Jan 7 '13 at 11:37

Your Answer


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

Browse other questions tagged or ask your own question.