Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i am using wildcard with apache


ServerAlias *
DocumentRoot /staronece1/domains

my named file

$ttl 38400      IN      SOA (
                        38400 )      IN      NS      IN      A  IN      A IN     A IN      A  IN      A  IN      A      IN      NS      IN      NS      IN      MX      10
* 14400 IN A
* IN A

my php test file



    function getBname(){
        return $bname[0];

    echo 'SubDomain is :'.getBname();

if i go to

i get this result SubDomain is : something

No the problem is

if i go to

i should get empty result, because www is not a sub domain

but i get this result

SubDomain is : www

And if i go to

i get firefox error message ( site not found )

How to fix this problem??

i think the solution is: added record for www in named file


share|improve this question
www is most definitely a subdomain. – Skyhawk Jul 7 '12 at 23:20
@Miles, How to fix this problem? – Alaa Gamal Jul 7 '12 at 23:27

2 Answers 2

As Miles commented, www is a regular subdomain that is no different to something. It's very misleading in that sense, and it's not your fault that you have them confused.

For one, the DNS zones are irrelevant: must resolve to something, or the website won't work at all, so leave that alone.

If you really want this behaviour, you need a separate ServerAlias before your current wildcarded ServerAlias.

Name-based virtual hosts for the best-matching set of s are processed in the order they appear in the configuration. The first matching ServerName or ServerAlias is used, with no different precedence for wildcards (nor for ServerName vs. ServerAlias).

share|improve this answer

Im not sure i understand what the problem is. The server is acting as it is supposed to. If the problem is that is not working, then add a dns record for and add another serveralias line to your httpd.conf:

ServerAlias *.*

ideally, add it below the other ServerAlias lines.

share|improve this answer

Your Answer


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.