K
K
krotish2010-12-26 21:55:30
Apache HTTP Server
krotish, 2010-12-26 21:55:30

Weird Apache behavior. virtual hosts?

There is a server (debian, there is an ISPConfig 3 panel ) with Apache. I create a virtual host trace. content:

<b>$ cat /etc/apache2/sites-enabled/example.com.vhost </b><br/>
&lt;Directory /var/www/example.com&gt;<br/>
 AllowOverride None<br/>
 Order Deny,Allow<br/>
 Deny from all<br/>

<VirtualHost *:80>
DocumentRoot /var/www/example.com/web
ServerName example.com
ServerAlias ​​www.example.com
ServerAdmin [email protected]
... www.example.com
actually opens correctly, but if you type example. com (without www), then the contents of the default virtual host are opened. By the way, here is its content:
<b>$ cat /etc/apache2/sites-enabled/default</b><br/>
&lt;VirtualHost *:80&gt;<br/>
 ServerAdmin [email protected]<br/>
<br/>
DirectoryIndex index.php index.htm index.html<br/>
 <br/>
 DocumentRoot /var/www/<br/>
 &lt;Directory /&gt;<br/>
 Options FollowSymLinks<br/>
 AllowOverride None<br/>

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
...
What could be the problem?

Answer the question

In order to leave comments, you need to log in

10 answer(s)
J
jamayka, 2010-12-27
@krotish

Try adding some ServerName for the default virtual host. From documentation:

If no ServerName is specified, then the server attempts to deduce the hostname by performing a reverse lookup on the IP address.

P
peter23, 2010-12-26
@peter23

DNS can't be involved here?

K
krotish, 2010-12-26
@krotish

yes, nothing suspicious,
the only suspicious thing is that there is no such problem with example.org - it comes in with and without www. Virtual host configs are exactly the same. But dns is definitely useless here)

V
Vas3K, 2010-12-27
@Vas3K

I had this on someone else's VDS with ISP Manager. He wrote some hosts not in sites-enabled as it should, but at the end of apache2.conf (or httpd.conf) because of which subdomains broke.

V
Vyacheslav Plisko, 2010-12-27
@AmdY

check if all the letters in the alias are written in English
usually, if there is an inexplicable problem, then an extra move was made.

R
rakot, 2010-12-27
@rakot

When everything seems to work for me, but it doesn’t work, then I create a new entity and it usually works (create a virtual host on test.com), and then turn test.com into example.com step by step, line by line, checking the correctness of work on each iterations. Thus, it is almost possible to solve almost any problem, if it has already completely reached a dead end.

D
Dimonich, 2010-12-27
@Dimonich

Did you restart Apache after the changes?

I
iTNitro, 2010-12-27
@iTNitro

show hosts file

B
Bodik, 2010-12-27
@Bodik

"NameVirtualHost *" is there exactly?
Let's check where example.com goes www.example.com - ping from your machine where you open them. Same way?
And in general it is strange that ServerName works in one virtualhost and ServerAlias ​​does not. I suspect that it's not Apache and virtual hosts, but somewhere a blunder.

S
ShamblerR, 2015-02-24
@ShamblerR

pancake though the domain tell.
as an option, write a virtual host for vvv separately, will it work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question