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
215 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
I wrote this article to explain some important DNS concepts that should be known to avoid some typical configuration errors I often see in forums. I assume that what is described here is the typical behavior of Microsoft DNS client. I don't know …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now