Forum Moderators: phranque
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>
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>
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]
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
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
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.