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
220 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DNS Domain Issues 10 31
linux - yum package installation issue 2 66
Domain Service Not Responding 14 30
RHEL 6.7 Gnome Desktop on VMware 6 VM 9 71
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

821 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