0

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

2 Answers 2

1

Add NameVirtualHost * to your configuration.

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

6
  • 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, 2012 at 11:17
  • @Dylan You still don't have NameVirtualHost * in your configuration? Dec 31, 2012 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, 2013 at 17:44
  • @Dylan A *:80 setting would definitely cause it to not function. It needs to match exactly to your vhosts. Jan 1, 2013 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, 2013 at 16:00
2

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
6
  • And now combine the reply of @ShaneMadden and mine and you'll get a working situation ;) Dec 30, 2012 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, 2012 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, 2012 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? Dec 30, 2012 at 20:44
  • updated orginal question with new virtualhost
    – Dylan
    Dec 31, 2012 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .