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
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

717 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