By default, the "mail.domain.com" subdomain routes to whatever "domain.com" go to; however, some users may not want this to happen for a multitude of reasons. One such reason is that if resources on the site are hardcoded to use the "domain.com.", visiting the site with "mail.domain.com" will present a 404 and not load those resources.
You can find a few ways that you can prevent this access below:
- 1. As "mail.domain.com" is an alias to "domain.com," the easiest way to remove this link would be to create a separate subdomain for the "mail.domain.com.". This can be done at (cPanel >> Home >> Domains >> Subdomains): https://docs.cpanel.net/cpanel/domains/subdomains/82/
- 2. A .htaccess redirect can redirect any request from "mail.domain.com" to "domain.com" instead. The following code could be placed in the document root's .htaccess for the domain:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mail.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mail.domain.com$
RewriteRule ^.*$ "https\:\/\/domain\.com" [R=301,L]
The 1st method is preferable as it does not interfere or conflict with any other rules that may already exist within the .htaccess. So be aware of this before using the 2nd method.