Account Management
Change document root for cPanel account primary domain
This function changes the document root for a cPanel account's primary domain.
To change the document root for an addon domain or subdomain, use the cPanel UAPI SubDomain::changedocroot function instead.
Important:
- The target directory must already exist before you call this function. The API function does not create it.
- This function does not move any files. You must ensure that the files exist in the new path when you call this function.
- Any parked domains (ServerAlias entries) on the affected domain will inherit the new document root.
- AutoSSL HTTP-01 renewals will fail if the new document root is empty or missing at renewal time.
- To revert a document root change, call this function again with the original path.
get/set_primary_domain_docroot
Query parameters
docrootstring path required
Example:public_html/myapp/public
The new document root as a path relative to the account's home directory. The path must begin with public_html/, and the target directory must already exist.
usernamestring username required
Example:username
The cPanel account username whose primary domain's document root you want to change.
Response
HTTP Request was successful.
Example response
{
"data": {
"documentroot": "/home/username/public_html/myapp/public"
},
"metadata": {
"command": "set_primary_domain_docroot",
"reason": "OK",
"result": 1,
"version": 1
}
}