Adding Multiple Alias Domains to cPanel

Posted in Developers

When you have a large list of alias (parked) domains to add to cPanel,  it’s best to automate the process as much as possible. I recently added about 100 domains using this method, which only requires a few free tools.

How to Bulk Add Alias Domains to cPanel

Step 1 – Getting the URL

cPanel uses URLs to trigger actions – that’s what allows this method to work.

  1. Log in to your cPanel and go to Aliases (called “Parked Domains” in older cPanel versions).
  2. Add the first domain in your list.
  3. Once the domain is added, you should see a “You succesfully created the alias” message. Stay on this page and copy the URL and paste it into a text file. It should look something like this (I emphasized parts that will be unique to you):
    http://yourdomain.com:2082/cpsess##########/frontend/cpanelskinname/park/doaddparked.html?domain=youraliasdomain.com&go=Add+Domain

Great, now that we have the URL responsible for adding parked domains, all we need to do is find a way to load it for each domain in the list, replacing the domain name to add (?domain=youraliasdomain.com).

Step 2 – Generating the list of URLs

This example will use PHP to generate the list, but you can use any scripting language you’re comfortable with.

We’ll be using a tool that allows you to execute a PHP script right in the browser, PHP Sandbox. You can either open the link below or run the script provided in your PHP environment of choice.

Open Script in PHP Sandbox


$output = ''; // will hold the list of URLs

// Enter your cPanel parked domains URL inside the quotes, 
// replacing the domain after ?domain= with *PLACEHOLDER*
$cpanel_alias_domains_url = '';

// Enter your domains inside the quotes, one per line
$domains = '
replaceme.com
replaceme2.com
replaceme3.com
';

// Split domains string into array, using new line characters as the separator
$domains = preg_split("/\r\n|\n|\r/", $domains);

// Generate the list of URLs
foreach ($domains as $domain) {
// Skip empty lines
if($domain == '') { continue; }
// Append new URL to output, replace placeholder with current domain
$output .= str_replace('*PLACEHOLDER*', $domain, $cpanel_alias_domains_url) . PHP_EOL;
}

echo $output;

Copy the output of the script and save it for this next step.

Step 3 – Loading Each URL

Now that we have a list of URLs, we need a tool to load them. Keep in mind that loading all the URLs at once is a bad idea, since it could overload your server, and slow down your website the more URLs you load at once.

I suggest using an extension for Firefox called Multi Open. It allows you to stagger opening each URL using a timed delay. Once you have that installed, paste in the URLs, set the “interval between open pages” to something like 5000 ms, and run it! You should see each URL load in a tab, one every five seconds. Ahhh… the sweet smell of automation.

 

 

← Back to Blog Index

Comments

    Leave a Reply

    ← Back to Blog Index