Eliminating subdomain name (test.example.com) from appearing in search engine but allowing (test.com) to appear

Operating System & Version
linux
cPanel & WHM Version
90.0 (build 18)

Owner/Operator

Registered
Dec 8, 2020
3
0
1
Edmonton
cPanel Access Level
Website Owner
In 20 years of webhosting, I have never had this issue before. Subdomains such as test.example.com are now appearing in search engines along with test.com. I just want test.com to appear in search engines not test.example.com. (example.com is in the root's public_html directory while test is in the root's test directory.) I changed web hosts earlier this fall and the problem never occurred previously, but is occurring with the new host. Could the issue be related to the transfer? What steps can be taken to rectify the situation? Is there something in CPanel that can be configured to stop this from occurring? Any assistance would be greatly appreciated. Thanks in advance.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,285
2,434
363
cPanel Access Level
Root Administrator
Hey there! Are you referring to addon domains, and not wanted the subdomain that gets them to work in Apache displayed? If so, the typical way to address this is to setup a redirect to ensure you are always pointing content to the full domain. Although this thread is old now, the information is still good:

 

Owner/Operator

Registered
Dec 8, 2020
3
0
1
Edmonton
cPanel Access Level
Website Owner
Thanks for the reply. I do want to keep the domain in public.html active. After some digging, I think it might be related to the .htaccess files not being transferred. I've come across the following and will place it to the test.com .htaccess file:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$
RewriteRule ^(.*)$ "https://www.test.com/" [R=301,L]
</IfModule>