Suppressing ServerAlias www.domain.com or specify new DocumentRoot

UltraMonk

Member
Dec 5, 2011
14
0
51
cPanel Access Level
Root Administrator
I have setup an account for one of my clients with their domain name, however their hostname of www.domain.com gets added as a ServerAlias to Apache pointing to their own accounts directory space.

I need to either suppress the creation of the www hostname so I can add that as a ServerAlias to a VirtualHost container I need to create for my own software

OR

be able to change where the DocumentRoot points too in the VirtualHost container for that account.

This comes back to my previous query in being able to create my own custom VirtualHost containers, but those custom VirtualHost containers are NOT required for the majority of domain names hosted on our cPanel enabled web server.

Any solutions?

Something else that I have discovered which is very very annoying, when adding in an addon domain it sets up a ServerName of SubDomain.AccountDomain.com

eg

Main Domain is domain1.com
Addon Domain is domain2.com

ServerName becomes domain2.domain1.com
with a
ServerAlias www.domain2.domain1.com

This is bloody awful, how can I stop this from happening?
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
To either remove the www.domain.com ServerAlias or change the DocumentRoot directive after account creation, both can be done in /var/cpanel/userdata/username/domain.com location. The settings in /var/cpanel/userdata build httpd.conf file.

After making any edits to /var/cpanel/userdata/username/domain.com location, you then would need to rebuild Apache and restart Apache:

Code:
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
Since you mention only doing this for some accounts, you could create a script that would revise /var/cpanel/userdata/username/domain.com after account creation, which you could run on accounts you want to revise after you've created the account.

Of note, I also want to mention that there is another template file that was never discussed in the last thread you had opened discussing the VirtualHost containers. That template is /usr/local/cpanel/etc/httptemplates/apache2_2/default which controls the VirtualHost template being built for newly created accounts. This is discussed at Changes Contained within a VirtualHost Directive location. You likely already know this, but in case you did not.

As for the addon domain question where subdomains are automatically created, I would not advise trying to stop that creation, since they are currently tied into how addon domains function under cPanel where the addon domain is the ServerAlias of the subdomain. If you try to remove or prevent the subdomain creation, you can possibly break the addon working. Instead, you may wish to post support onto the feature request where true multi-domain existence has been lodged --> http://forums.cpanel.net/f145/true-...ficates-ips-per-acct-case-40954-a-138917.html (specifically post http://forums.cpanel.net/f145/true-...-per-acct-case-40954-a-138917.html#post640973 where this is detailed in that thread).