Introduction
This article will walk you through the necessary steps for disabling the redirect associated with '/webmail' and other default redirects, e.g.:
domain.com/webmail
Procedure
To disable this redirect, we will first need to make a copy of the Apache template file:
cp -via /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
Next we will want to open the copied file ( /var/cpanel/templates/apache2_4/ea4_main.local ) in our preferred text edit and remove any of the following lines where we don't want a redirect to place:
ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi
ScriptAliasMatch ^/?webmail$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?webmail/ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
ScriptAliasMatch ^/Autodiscover/Autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
ScriptAliasMatch ^/autodiscover/autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
ScriptAliasMatch .* /usr/local/cpanel/cgi-sys/domainredirect.cgi
If we wanted to remove the 'webmail' redirect, we would remove the two lines containing '/?webmail', example:
ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
ScriptAliasMatch ^/Autodiscover/Autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
ScriptAliasMatch ^/autodiscover/autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
ScriptAliasMatch .* /usr/local/cpanel/cgi-sys/domainredirect.cgi
Once this has been completed, we need to rebuild the Apache configuration file and restart the Apache service:
/scripts/rebuildhttpdconf && /scripts/restartsrv_httpd
Now we can confirm that the '/webmail' redirect no longer takes place.
[root@cpanel apache2_4]# curl -IL cptech.test/webmail
HTTP/1.1 404 Not Found
Date: Fri, 06 Nov 2020 01:08:03 GMT
Server: BNI
Strict-Transport-Security: max-age=300; includeSubDomains; preload
Content-Type: text/html; charset=iso-8859-1
note: replace cptech.test with the url of a domain on your server