The ‘Addon Domains’ feature in cPanel is excellent, as it allows you to host multiple domain names under your cPanel account. Although an add-on domain is treated as a completely independent domain name, allowing you to host a website, the way it is added within the Apache configuration file works slightly differently from the primary domain name. However, cPanel creates a virtual host (vhost) for the domain name, as a subdomain of the primary domain name. For example, if the primary domain name is mywebsite.hu and you add the domain name myblog.com as an additional domain, cPanel creates a virtual host under the address myblog.mywebsite.hu. To achieve full domain name functionality, Apache then sets blogom.com as an alias for ablogom.weboldalam.hu, which ultimately allows people to view the content of the subdomain whilst typing the actual domain name into their browser.
Unfortunately, the subdomain will most likely be accessible alongside the domain added as a supplement, which means Google may index the content twice under separate URLs, potentially harming your website’s ranking.
To avoid this, you can use two different approaches. In this article, we’ll look at both, and you can decide which one is best for you:
.htaccess method
This method revolves around adding a rewrite rule that displays a 404 Not Found error when the subdomain is visited. To use this method, you need to add the following code snippet to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} blogom.weboldalam.hu$
RewriteRule ^(.*)$ "https://blogom.com/" [R=301,L]
Please replace “blogom.weboldalam.hu” with the subdomain that was created when you added your domain name as an add-on, and replace “blogom.com” with the actual add-on domain name.
How to modify A records
In contrast to the method described above, you can change the A record associated with the subdomain created by the add-on domain so that it points to a non-existent IP address or to 127.0.0.1 (localhost), which resolves the subdomain to that IP address, thereby making it inaccessible.