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.

Here is my apache configuration file. I have two domain names running on same ip but i want them to point to different webapps. But in this case both point to the one intended for e-yantra.org.

If I copy paste akshar.co.in part before E-yantra.org both start pointing to akshar.co.in

I have two A DNS entries (one per domain name) pointing to the same IP.

NameVirtualHost *:80


<VirtualHost *:80>
    ServerName www.e-yantra.org
    ServerAdmin webmaster@e-yantra.org
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride All 
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    <Directory /var/www/ci/>
        Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
    </Directory>
    <Directory /var/www/db2/>
        Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

<VirtualHost *:80>
    ServerName www.akshar.co.in
    ServerAdmin webmaster@akshar.co.in
    DocumentRoot /var/akshar.co.in

    <Directory /var/akshar.co.in/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you go to "www.akshar.co.in" it goes to your test page (i.e. "hello world").

Your problem is this:

ServerName www.akshar.co.in

It does not match when you simply type "akshar.co.in" as the URL, even though DNS points you to the right IP address.

I would recommend the following addition:

ServerAlias akshar.co.in *.akshar.co.in

This will allow Apache to catch URLs that do not include "www" (as well as any other sub-domains) and associate it them with the proper virtual host.

I would also recommend an equivalent statement in the other virtual host definition as well (to make sure things work properly if you expand and add more sites to the server).

share|improve this answer
    
But I have a CNAME entry that points www.akshar.co.in to akshar.co.in –  Eastern Monk Mar 12 '11 at 18:36
1  
That's not really relevant. You DNS records are fine (you get to the right IP address). Seperate from that, Apache is simply processing the URL provided in the HTTP request and matching it against what you have in your configuration. –  chuckx Mar 13 '11 at 18:51

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.