How to change domain.com/webmail to mail.domain.com

Change domain.com/webmail to mail.domain.com

By default, the proxy subdomains whm.domain.tld, cpanel.domain.tld and webmail.tld will work, without you needing to create a subdomain yourself. Simply make sure that Add proxy VirtualHost to httpd.conf to automatically redirect unconfigured cpanel, webmail, webdisk and whm subdomains to the correct port (requires mod_rewrite and mod_proxy) is checked in Main >> Server Configuration >> Tweak Settings, in the WebHost Manager.

You will probably also want to check Automatically create cpanel, webmail, webdisk and whm proxy subdomain DNS entries for new accounts, also in Main >> Server Configuration >> Tweak Settings.

If you do not host your own DNS on your cPanel server, you will need to make sure that the subdomain A records are created in the DNS zone for your domain on the server that hosts the zone.

The proxy subdomains redirect cPanel/WHM/Webmail traffic over port 80, instead of the normal cPanel ports, which makes them useful for users who may be behind a firewall that does not allow access to the normal ports for cPanel/WHM/Webmail.

 

1. Create an ‘A’ record for the sub-domain ‘webmail’ in the DNS zone file. It should look like :

domain.com. IN A XX.XX.XXX.XXX
localhost.domain.com. IN A 127.0.0.1
domain.com. IN MX 0 domain.com.
mail IN CNAME domain.com.
www IN CNAME domain.com.
ftp IN A XX.XX.XXX.XXX
cpanel IN XX.XX.XXX.XXX
whm IN A XX.XX.XXX.XXX
webmail IN A XX.XX.XXX.XXX
webdisk IN A XX.XX.XXX.XXX

2. Put the following code inside .htaccess in the sub-domain folder ( virtual sub-domain which doesn’t have an entry in httpd.conf

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.webmail.domain.com$
RewriteRule ^.*$ “http\:\/\/domain\.com\/webmail” [R=301,L]

OR

Simpler .htaccess rule which you can set at the root of a cPanel account so it can affect all addon domains and best of all.

# Redirect webmail.domain.tld to domain:2095 for cPanel Webmail only
RewriteCond %{HTTP_HOST} ^webmail\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/webmail/$1 [R=301,L]

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: