main domain and sub-domain are promiscuous

My site with the main domain name www.mysite.com works well before. (I use mysite to hide my actual domain name here)

I want to add sub.mysite.com for another virtual host on my host.

I follow http://davidpodley.com/2010/02/11/setti … nd-apache/">http://davidpodley.com/2010/02/11/setting-up-subdomains-in-linode-and-apache/ and after I do

****a2ensite sub.mysite.com

/etc/init.d/apache2 restart****

some users of www.mysite.com will access sub.mysite.com not www.mysite.com. I can found them in /srv/www/sub.mysite.com/logs/access.log and they tell me the problem. They should only access www.mysite.com. However, it works well on my PC.

Why the users of www.mysite.com go to sub.mysite.com? Can anyone help me?

–-------------------------------------------------

Some informations:

My A Records is:

Hostname IP Address TTL Options

96.126.98.96 Default Edit | Remove

sub 96.126.98.96 Default Edit | Remove

mail 96.126.98.96 Default Edit | Remove

www 96.126.98.96 Default Edit | Remove

my hostname is mysite, and my /etc/hosts is

127.0.0.1 localhost.localdomain localhost

96.126.98.96 mysite.mysite.com mysite

apache2ctl -S:

VirtualHost configuration:

wildcard NameVirtualHosts and default servers:

*:443 is a NameVirtualHost

default server mysite.com (/etc/apache2/sites-enabled/mysite.com:10)

port 443 namevhost mysite.com (/etc/apache2/sites-enabled/mysite.com:10)

*:80 is a NameVirtualHost

default server sub.mysite.com (/etc/apache2/sites-enabled/sub.mysite.com:1)

port 80 namevhost sub.mysite.com (/etc/apache2/sites-enabled/sub.mysite.com:1)

port 80 namevhost mysite.com (/etc/apache2/sites-enabled/mysite.com:1)

cat /etc/apache2/sites-enabled/mysite.com

ServerAdmin mysite@gmail.com

ServerName mysite.com

ServerAlias www.mysite.com

DocumentRoot /srv/www/mysite.com/public_html/

ErrorLog /srv/www/mysite.com/logs/error.log

CustomLog /srv/www/mysite.com/logs/access.log combined

SSLEngine On

SSLCertificateFile /etc/apache2/ssl/apache.pem

SSLCertificateKeyFile /etc/apache2/ssl/apache.key

ServerAdmin mysite@gmail.com

ServerName mysite.com

ServerAlias www.mysite.com

DocumentRoot /srv/www/mysite.com/public_html/

ErrorLog /srv/www/mysite.com/logs/error.log

CustomLog /srv/www/mysite.com/logs/access.log combined

cat /etc/apache2/sites-enabled/sub.mysite.com

ServerAdmin mysite@gmail.com

ServerName sub.mysite.com

ServerAlias www.sub.mysite.com

DocumentRoot /srv/www/sub.mysite.com/public_html/

DocumentRoot /srv/www/mysite.com/public_html/sub

ErrorLog /srv/www/sub.mysite.com/logs/error.log

CustomLog /srv/www/sub.mysite.com/logs/access.log combined

1 Reply

It's resolved.

Some users access my main domain site with IP directly.

In apache2ctl -S result, we can see

default server sub.mysite.com

According apache explanation, the first in the configuration file has the highest priority and can be seen as the default or primary server.

In my server, /etc/apache2/sites-enabled, rename mysite.com to 000mysite.com will make it be loaded before sub.mysite.com (in my site, "sub" is "f*")

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct