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.

Running Apache on CentOS, trying to setup wildcard subdomains, basically I want .mydomain.com to point to mydomain.com

With cPanel I added *.mydomain.com With WHM I made sure that A record is pointing to the right IP.

I set my A record:

* 14400 IN X.x.x.x 

My httpd.conf:

 ServerName _wildcard_.mydomain.com
    ServerAlias *.mydomain.com
DocumentRoot /home/mydomain/public_html
ServerAdmin webmaster@mydomain.com
UseCanonicalName Off

## User userdomain# Needed for Cpanel::ApacheConf
UserDir enabled userdomain
<IfModule mod_suphp.c>
    suPHP_UserGroup userdomain userdomain
</IfModule>
<IfModule !mod_disable_suexec.c>
    <IfModule !mod_ruid2.c>
        SuexecUserGroup usergrdomain userdomain
    </IfModule>
</IfModule>
<IfModule mod_ruid2.c>
    RUidGid userdomain userdomain
</IfModule>
ScriptAlias /cgi-bin/ /home/mydomain/public_html/cgi-bin/


# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/mydomain/wildcard_safe.mydomain.com/*.conf"

I have my VirtualHost in httpd.conf set to point to domain root. Restarted Apache, server, dns, still nothing.

I have spent hours researching this, followed instructions, set everything correctly.

What am I missing?

share|improve this question
4  
You forgot to say what doesn't work. –  Michael Hampton Mar 12 '13 at 23:00

1 Answer 1

ServerAlias directive is valid only in VirtualHost context.

See: http://httpd.apache.org/docs/2.2/mod/core.html#serveralias

Your config should be:

<VirtualHost *:80>
    ServerName _wildcard_.mydomain.com
    ServerAlias *.mydomain.com
    DocumentRoot /home/mydomain/public_html
    ServerAdmin webmaster@mydomain.com
    UseCanonicalName Off

    ## User userdomain# Needed for Cpanel::ApacheConf
    UserDir enabled userdomain
    <IfModule mod_suphp.c>
        suPHP_UserGroup userdomain userdomain
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup usergrdomain userdomain
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RUidGid userdomain userdomain
    </IfModule>
    ScriptAlias /cgi-bin/ /home/mydomain/public_html/cgi-bin/
</VirtualHost>
share|improve this answer

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.