Change webmail.domain.com to mail.domain.com in WHM&cPanel

cuongvttt

Active Member
Jun 26, 2008
37
2
58
Hello guys,

Could you show me how to change webmail.domain.com to mail.domain.com in WHM&cPanel? so if my customers want to visit the webmail they just type mail.theirdomain.com

Thanks
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Hey there! Unfortunately there is not an easy way to do that inside cPanel. cPanel specifically programs the existing proxy subdomains of cpanel, whm, webmail, autoconfig, autodiscover, cpcalendars, cpcontacts, and webdisk directly into the Apache and DNS configurations. In order to change this, you would need to make manual configuration changes to the Apache template system, and also adjust the DNS templates so those zone get created automatically.

While I don't have specific instructions for that work, documentation on Apache templates can be found here:


and I'd recommend performing this work on a test system with no live accounts first to ensure you get the configuration working how you expect.
 

MotazHakim

Member
Oct 12, 2021
20
3
3
Egypt
cPanel Access Level
Root Administrator
Hello
There's an easy way, since cPanel/WHM is not giving an easy way to do it

using a .htaccess file with the below code:


PHP:
RewriteCond %{HTTP_HOST} ^ mail.theirdomain.com  [NC,OR]
RewriteRule ^(.*)$ https://webmail.domain.com/$1 [L,R=301,NC]
and put it in
Bash:
/home/accountname/public_html/
so the file will be at
Bash:
 /home/accountname/public_html/.htaccess
then clear browser cache
then now try to access mail.theirdomain.com then you will find it redirect the customer automatically to webmail.domain.com
No need to do any edit.

Try it and send feedback;)
 
  • Like
Reactions: mlopez and cPRex

mlopez

Well-Known Member
Dec 17, 2020
54
7
8
Maldonado - Uruguay
cPanel Access Level
Root Administrator
Twitter
Hello
There's an easy way, since cPanel/WHM is not giving an easy way to do it

using a .htaccess file with the below code:


PHP:
RewriteCond %{HTTP_HOST} ^ mail.theirdomain.com  [NC,OR]
RewriteRule ^(.*)$ https://webmail.domain.com/$1 [L,R=301,NC]
and put it in
Bash:
/home/accountname/public_html/
so the file will be at
Bash:
 /home/accountname/public_html/.htaccess
then clear browser cache
then now try to access mail.theirdomain.com then you will find it redirect the customer automatically to webmail.domain.com
No need to do any edit.

Try it and send feedback;)
Great hack, but if @cuongvttt wanted to make the change server wide it could be annoying.