wildcard deal with www as a subdomain

Posted by Alaa Gamal on Server Fault See other posts from Server Fault or by Alaa Gamal
Published on 2012-07-07T22:36:34Z Indexed on 2012/07/08 3:17 UTC
Read the original article Hit count: 437

Filed under:

i am using wildcard with apache

my APACHE CONFIG:

ServerAlias *.staronece1.com
DocumentRoot /staronece1/domains

my named file

$ttl 38400
staronece1.com.      IN      SOA     staronece1.com. email.yahoo.com. (
                        1334838782
                        10800
                        3600
                        604800
                        38400 )
staronece1.com.      IN      NS      staronece1.com.
staronece1.com.      IN      A       95.19.203.21
www.staronece1.com.  IN      A       95.19.203.21
server.staronece1.com. IN     A      95.19.203.21
mail.staronece1.com. IN      A       95.19.203.21
ns1.staronece1.com.  IN      A       95.19.203.21
ns2.staronece1.com.  IN      A       95.19.203.21
staronece1.com.      IN      NS      ns1.staronece1.com.
staronece1.com.      IN      NS      ns2.staronece1.com.
staronece1.com.      IN      MX      10 mail.staronece1.com.
* 14400 IN A 95.19.203.21
*.staronece1.com IN A 95.19.203.21

my php test file

/staronece1/domains/index.php



<?php

    function getBname(){
        $bname=explode(".",$_SERVER['HTTP_HOST'],2);
        return $bname[0];
    }

    echo 'SubDomain is :'.getBname();
?>

if i go to something.staronece1.com

i get this result SubDomain is : something

No the problem is

if i go to www.staronece1.com

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 www.something.staronece1.com

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

Thanks

© Server Fault or respective owner

Related posts about apache2