LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Virtual host www.domain.com work, domain.com don't work (https://www.linuxquestions.org/questions/linux-networking-3/virtual-host-www-domain-com-work-domain-com-dont-work-441291/)

stormrider_may 05-03-2006 12:41 PM

Virtual host www.domain.com work, domain.com don't work
 
Hi, i'm having a problem with a virtual host. Well actually all of them. When someone try to access for example www.domain.com it works great, my server act as the virtual host of that domain. But if someone try to access domain.com my server doesn't act as it's virtual host and just redirect it to "/".
I hope someone could help me to solve this.

Here is the virtual host conf

Code:

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName www.domain.com
  DocumentRoot "/var/www/domain.com"
</VirtualHost>

Here is the master dns conf

Code:

$TTL    86400
; Authoritative data for domain.com
;
@                IN    SOA ns1.domain.com. root.domain.com. (
                        1139830917      ; Serial (yymmddxx)
                        28800          ; refresh, seconds
                        7200            ; retry, seconds
                        604800          ; expire, seconds
                        86400 )        ; minimum, seconds

domain.com.  IN  NS    ns1.domain.com.
domain.com.  IN  NS    ns2.domain.com.
domain.com.  IN  NS    ns3.domain.com.
                MX 0        mail
domain.com. IN A my_webserver_ip
ns1            IN      A            my_first_dns_ip
ns2            IN      A            my_second_dns_ip
ns3            IN      A            my_third_dns_ip
mail          IN      A            my_mailserver_ip
www            CNAME                  domain.com.

Another question, why dns is so hard to conf? :(

scowles 05-03-2006 06:03 PM

Try adding "ServerAlias mydomain.com" to your virtual definition.

vimal 05-03-2006 08:53 PM

Hello

In the configuration of virtual hosting,try adding the domain name mydomain.com.


ie..

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.com domain.com
DocumentRoot "/var/www/domain.com"
</VirtualHost>

Got it?

I hope this works.


Thanks,

stormrider_may 05-03-2006 09:24 PM

Yes i tried this, but got this error

Code:

ServerName takes one argument, The hostname and port of the server
When reloading apache

vimal 05-03-2006 09:52 PM

Hello stormrider_may,

Really sorry to say that, I was not in my senses, i think. You must add 'ServerAlias' not 'ServerName'.

ie..

NameVirtualHost *:80
<VirtualHost *:80>
ServerAlias www.domain.com domain.com
DocumentRoot "/var/www/domain.com"
</VirtualHost>

Thanks,,


All times are GMT -5. The time now is 11:36 AM.