Automatic subdomain for new customers?

esthos

Registered
Jan 1, 2018
1
0
1
AU
cPanel Access Level
Root Administrator
Hi all.

I am the administrator of a server running the latest cpanel/whm versions on CentOS 6.9.

I have a subdomain mycompany.com - I wish to allocate all new clients username.mycompany.com upon signup.

This is in addition to any domains they are bringing with them.

Is there a way I can do this?

I am resisting using mod_dir for security reasons.

mycompany.com is owned by another user on the system, so if this presents a problem I am happy to use mycompany2.com

Thanks in advance for any help.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

Is this for the purpose of providing them with a temporary URL to access their websites? If so, you could setup a custom bash script that uses the cPanel API 2 "Park" function, and then configure that script to run automatically during the account creation process using a post "Accounts::Create" hook to automatically set up the alias (parked domain) upon account creation. Here are some documents to help you get started should you want to set this up:

Guide to Standardized Hooks - Software Development Kit - cPanel Documentation
Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation
cPanel API 2 Functions - Park::park - Software Development Kit - cPanel Documentation

Another option is to simply offer instructions to end-users regarding the use of the hosts file on their computers to temporarily access their domain names before they resolve to the cPanel server:

How to Modify your hosts File - cPanel Knowledge Base - cPanel Documentation

Thank you.