Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have my apache server set up and I subdomains are linked to an application which will then find the appropriate database to work with or exit if it does not exist

So for that I have an *.domain.tld

But now I do need some subdomains for the server apps for example phpmyadmin.domain.tld

So I have set it up like this

<VirtualHost *>
DocumentRoot "/var/www/phpmyadmin"
ServerName phpmyadmin.domain.tld
<Directory "/var/www/phpmyadmin">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/hidden/app/public
ServerName *.domain.tld
<Directory "/var/www/hidden/app/public">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

But this way it always goes to phpmyadmin wathever I give test.domain.tld phpmyadmin.domain.tld helpme.domain.tld etc.

And If I put the second virtualhost (the *.domain.tld one) It wont go to phpmyadmin.domain.tld but just to the application

What am I doing wrong?

Update:

Still not working

This way it shows only phpmyadmin whatever I go to test.domain.tld phpmyadmin.domain.tld etc.

<VirtualHost *>
DocumentRoot /var/www/phpmyadmin
<Directory "/var/www/phpmyadmin">
allow from all
Options +Indexes
</Directory>
ServerName phpmyadmin.domain.tld
ServerAlias phpmyadmin.domain.tld
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/hidden/app/public
ServerName domain.tld
ServerAlias *.domain.tld
<Directory "/var/www/hidden/app/public">
Allowoverride All
allow from all
Options +Indexes
</Directory>
</VirtualHost>

This way it only shows the app whatever I go to test.domain.tld phpmyadmin.domain.tld etc

<VirtualHost *>
DocumentRoot /var/www/hidden/app/public
ServerName domain.tld
ServerAlias *.domain.tld
<Directory "/var/www/hidden/app/public">
Allowoverride All
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/phpmyadmin
<Directory "/var/www/phpmyadmin">
allow from all
Options +Indexes
</Directory>
ServerName phpmyadmin.domain.tld
ServerAlias phpmyadmin.domain.tld
</VirtualHost>

apachectl -S output

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    phpmyadmin.domain.tld (/etc/httpd/conf/httpd.conf:1015)
*:*                    domain.tld (/etc/httpd/conf/httpd.conf:1025)
Syntax OK
share|improve this question

2 Answers 2

up vote 1 down vote accepted

Add NameVirtualHost * to your configuration.

(If that doesn't do the trick, provide the output from apachectl -S.)

share|improve this answer
    
updated original question, I said it was half working yesterday but I believe it was just cached because now it just is still not working at all, and yes I do restart apache every time I make changes –  Dylan Dec 31 '12 at 11:17
    
@Dylan You still don't have NameVirtualHost * in your configuration? –  Shane Madden Dec 31 '12 at 16:18
    
I had it uncommented already but it was NameVirtualHost *:80 Even tough I expected that to be fine, I removed the :80 and it works now. Seems odd and maybe it is something else but I'am glad it works now (I'am getting the feeling the paged were cached and gave me different results) –  Dylan Jan 1 '13 at 17:44
    
@Dylan A *:80 setting would definitely cause it to not function. It needs to match exactly to your vhosts. –  Shane Madden Jan 1 '13 at 18:48
    
Oh now I understand it conflicts with the <VirtualHost *>, so if I'd want NameVirtualHist *:80 to work I had to go for <VirtualHost *:80>? –  Dylan Jan 2 '13 at 16:00

The ServerName directive does not allow the use of wildcards. For this you need the ServerAlias.

So make it something like

ServerName somethingelse.domain.tld
ServerAlias *.domain.tld
share|improve this answer
    
And now combine the reply of @ShaneMadden and mine and you'll get a working situation ;) –  bartlaarhoven Dec 30 '12 at 19:49
    
Thank you very much sir, strange that webmin doesn't have an option for this (no problems doing it manually but I'd expect if they offer a GUI for it, it supports common features) –  Dylan Dec 30 '12 at 20:14
    
Still does not function optimal, if I go to phpmyadmin.domain.tld it works as soon as I log on and it goes to phpmyadmin.domain.tld/index.php it goes to the app (*.domain.tld) –  Dylan Dec 30 '12 at 20:21
    
@Dylan Can you post your new VirtualHost configuration? To get a complete overview and check for the reason for that to happen? –  bartlaarhoven Dec 30 '12 at 20:44
    
updated orginal question with new virtualhost –  Dylan Dec 31 '12 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.