Solved

Apache issues - why am i getting a different website when I omit the www prefix from the domain?

Posted on 2008-10-02
6
219 Views
Last Modified: 2012-05-05
I recently set up 2 different websites on my linux/apache based dedicated server.

http://www.atzilut.com

http://www.dhoofhaken.com

I set up atzilut.com first, .. and then set up dhoofhaken.com a few days later.

Why is it that when I omit the "www" prefix when trying to pull up the dhoofhaken.com website -- I  get the atzilut.com website?

http://dhoofhaken.com

How can I fix this?  Below are the contents of my httpd_conf, named.conf, and dns zone files.

Thanks in advance,
- Yvan

----------------------------------------------------
httpd.conf (irrelevant content stripped out)
----------------------------------------------------

<virtualHost *:80>
ServerAdmin yvan@atzilut.com
DocumentRoot /var/www/html/atzilut
ServerName www.atzilut.com
ServerAlias www.atzilut.com
ServerAlias atzilut.com
ErrorLog logs/atzilut_log
CustomLog logs/atzilut-access_log combined
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/dhoofhaken
<Directory "/var/www/html/dhoofhaken">
allow from all
Options +Indexes
</Directory>
ServerName www.dhoofhaken.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/atzilut/blog
ServerName blog.atzilut.com
<Directory "/var/www/html/atzilut/blog">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/phpMyAdmin
ServerName mysql.atzilut.com
<Directory "/var/www/html/phpmyadmin">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

----------------------------------------------------
named.conf
----------------------------------------------------

// Default named.conf generated by install of bind-9.2.4-2
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        #Recursion no;
};
include "/etc/rndc.key";

zone "atzilut.com" IN {
      type master;
      file "atzilut.com.zone";
      allow-update { none; };
      allow-transfer { none ; };
};

zone "dhoofhaken.com" IN {
      type master;
      file "dhoofhaken.com.zone";
      allow-update { none; };
      allow-transfer { none ; };
};

----------------------------------------------------
atzilut.com.zone
----------------------------------------------------

$TTL 86400
$ORIGIN atzilut.com.
@      IN      SOA      ns1.atzilut.com. yvan.atzilut.com. (
                  2004042601      ; serial
                  21600            ; refresh
                  3600            ; retry
                  604800            ; expires
                  86400 )            ; minimum

      IN      NS            ns1.atzilut.com.
      
      IN      NS            ns2.atzilut.com.

      IN      MX      10      mail.atzilut.com.

      IN      A            63.134.253.164

ns1      IN      A            63.134.253.164
ns2      IN      A            63.134.254.164
www      IN      A            63.134.253.164
ftp      IN      A            63.134.253.164
blog      IN      A            63.134.253.164
mysql      IN      A            63.134.253.164
mail      IN      A            63.134.254.164

----------------------------------------------------
dhoofhaken.com.zone
----------------------------------------------------

$TTL 86400
$ORIGIN dhoofhaken.com.
@      IN      SOA      ns1.dhoofhaken.com. yvan.dhoofhaken.com. (
                  2004042601      ; serial
                  21600            ; refresh
                  3600            ; retry
                  604800            ; expires
                  86400 )            ; minimum

      IN      NS            ns1.dhoofhaken.com.
      
      IN      NS            ns2.dhoofhaken.com.

      IN      MX      10      mail.dhoofhaken.com.

      IN      A            63.134.253.164

ns1      IN      A            63.134.253.164
ns2      IN      A            63.134.254.164
www      IN      A            63.134.253.164
ftp      IN      A            63.134.253.164
blog      IN      A            63.134.253.164
mail      IN      A            63.134.254.164



0
Comment
Question by:egoselfaxis
6 Comments
 
LVL 9

Expert Comment

by:khaledf
ID: 22629953
try to remove this line
ServerAlias www.atzilut.com

and add this line after "ServerName www.dhoofhaken.com"
ServerName dhoofhaken.com

then restart apache
0
 
LVL 9

Accepted Solution

by:
khaledf earned 500 total points
ID: 22629963
sorry
"...and add this line after "ServerName www.dhoofhaken.com"
ServerName dhoofhaken.com  ..."

should be

and add this line after "ServerName www.dhoofhaken.com"
ServerAlias dhoofhaken.com
0
 
LVL 23

Expert Comment

by:Mysidia
ID: 22630673
Because it is a different domain  than your ServerName line for the name-based virtual host.
I would use instead:

ServerName www.atzilut.com
ServerAlias atzilut.com *.atzilut.com


If you want all subdomains of that domain to show the same site.



0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 27

Expert Comment

by:caterham_www
ID: 22632480
> Why is it that when I omit the "www" prefix when trying to pull up the dhoofhaken.com website -- I  get the atzilut.com website?

Because if none <virtualhost...> matches the HTTP_HOST, with name-based virtual hosts, the first one will be taken. That's why you get the atzilut.com website.
0
 

Author Comment

by:egoselfaxis
ID: 22633093
Thanks khaledf.  Adding the ServerAlias attribute did the trick.

- Yvan
0
 
LVL 9

Expert Comment

by:khaledf
ID: 22633601
glad things are working as expected.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question