Forum Moderators: phranque

Message Too Old, No Replies

Problems with my vhosts

Vhosts work for some domains, but for other domains they don't.

         

Biganon

9:38 pm on Oct 16, 2009 (gmt 0)

10+ Year Member



Hello ! :)

I have big problems with my vhosts, and behaviours I can not understand !

To put it easy, I threw everything away, and I'm setting the things back up step by step, maybe you can help ;)

I have a server and a few domain names, which lead to that server. With bind, I manage all those domain names, and then with Apache I try and manage the subdomains... But while it's working fine for... well, two of my domains, the other ones have problems ! I'll start with one problematic domain name... we'll see the others later, maybe.

Well, first question : Is it possible to manage the subdomains of all my domains in a dynamic way ? I mean : Accessing [blabla.example.com,...] redirect to /home/big-example/domain/blabla ? Because on IRC, I've been "kindly" told that it wasn't possible...
But it surprises me, because a friend of mine is able to do it, I guess.

So, in sites-enabled I have one file per domain name, and here is their content (with one different domain name and document root for each of them, of course):


<VirtualHost *:80>
DocumentRoot /home/big-example/big-example/www
ServerAlias www.big-example.com
ServerName big-example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/big-example/big-example/arene
ServerName arene.big-example.com
</VirtualHost>

I have NameVirtualHost *:80 located in ports.conf for information. 000-default, I threw it away.
SO as you can see, it's non-dynamic, I'm really going step by step. So this domain works fine, and so does its subdomain "arene".
Then I have a second domain, which works fine too, even its ServerAlias.

The problem is for the third one. I've set ip up like that :


<VirtualHost *:80>
DocumentRoot /home/big-example/example90/www
ServerName example90.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/big-example/example90/www
ServerName www.example90.com
</VirtualHost>

Just like the other one... but, example90.com leads where it's supposed to, but www.example90.com does NOT ! It leads to the index of the first domain (big-example.com), which is kinda weird.

I can avoid that by creating a second VirtualHost for example90.com, expliciting that www.example90.com must lead to /home/big-example/example90/www... But it isn't normal that the ServerAlias doesn't work !

So, how could I manage to get this ServerAlias working, just like the one I use in the other domains ? Why does this one not work, while the other ones work ?

Thank you very much, and sorry for my weird language, I'm Swiss actually. ++

[edited by: jdMorgan at 2:12 am (utc) on Oct. 17, 2009]
[edit reason] example.com, etc. [/edit]

jdMorgan

10:01 pm on Oct 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) Where is the NameVirtualHost directive?

2) Are you restarting your server after every change to the configuration?

3) Have you read this Apache document [httpd.apache.org] (or the correct version for your Apache server release)?

4) If no VirtualHost is matched, then content is served from the first vHost found, which may explain your so-called "redirect" behaviour (Have you looked at the HTTP headers in the transaction using Live HTTP Headers or a similar add-on? I'll bet it is not a 301 or 302 redirect...)

No trouble with the "Swiss-English" so far... :)

Jim

Biganon

11:09 pm on Oct 16, 2009 (gmt 0)

10+ Year Member



Hello Jim !

1) The NameVirtualHost is located in ports.conf... Well, if I understood correctly, I just need NameVirtualHost *:80 to appear once in my configuration ? That's why I left it where it was, in ports.conf. But I can be mistaken :D

2) Yes, I am

3) I've read it now (in French and for Apache 2.2), and tried to understand it.

Should I have to use UseCannonicalName false ? Or is it something completely different ?

Thank you for your answer

Simon

jdMorgan

2:08 am on Oct 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"UseCanonicalName off" usually causes the least trouble, but that's not likely the cause of your problem.

Jim

Caterham

12:19 pm on Oct 17, 2009 (gmt 0)

10+ Year Member



Well, first question : Is it possible to manage the subdomains of all my domains in a dynamic way ? I mean : Accessing [blabla.example.com,...] redirect to /home/big-example/domain/blabla ? Because on IRC, I've been "kindly" told that it wasn't possible...

See mod_vhost_alias [httpd.apache.org].

But it isn't normal that the ServerAlias doesn't work !

It's mostly caused by some non-visible characters.

Biganon

12:27 pm on Oct 17, 2009 (gmt 0)

10+ Year Member



I've been told about non-visible characters once, yes. What should I use to edit the files ? For I use vim through a terminal, but maybe the encoding isn't the same...

Thx

Biganon

12:30 am on Oct 19, 2009 (gmt 0)

10+ Year Member



I solved my problem. In one word : Lighttpd. :D