[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
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
Medium Priority
?
230 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 2000 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month20 days, 11 hours left to enroll

865 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