The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I want /webmail gone!

Discussion in 'E-mail Discussions' started by jspierre, Mar 3, 2011.

  1. jspierre

    jspierre Member

    Joined:
    Mar 3, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I've searched for the answer to this, but I can't seem to find anything specific. Here's what I want to do:

    I want to completely remove the /webmail ability for all domains on the server. By default, this points to cPanel's webmail login, but I do not want this available to any domain. So, I need http://www.mydomain.com/webmail and https://www.mydomain.com/webmail to DO NOTHING (except return a "404 Not Found" error).

    I realize that, once this is done, you can still get to the webmail interface using the port numbers (mydomain.com:2095, etc.); that's fine and I want to leave that alone. The only thing I'm concerned about is the /webmail URL. I want that special redirection to be removed.

    How can I do this? Can this be done?

    Any help would be appreciated!
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    First of all, ensure that WHM > Tweak Settings has these all set to "Off":

    Next, you are going to have to modify the template file to remove the option for webmail in it:

    Code:
    cp /var/cpanel/templates/apache2/main.default /var/cpanel/templates/apache2/main.local
    vi /var/cpanel/templates/apache2/main.local
    You'll need to change these lines:

    Code:
    ErrorLog [% main.errorlog.item.errorlog %]
    DefaultType [% main.defaulttype.item.defaulttype %]
    [% FOREACH dir IN main.scriptaliasmatch.items -%]
    ScriptAliasMatch [% dir.regex %] [% dir.path %]
    [% END -%]
    To these lines:

    Code:
    ErrorLog [% main.errorlog.item.errorlog %]
    DefaultType [% main.defaulttype.item.defaulttype %]
    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
    This yanks out this line that normally builds into Apache's /usr/local/apache/conf/httpd.conf configuration file:

    Code:
    ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi 
    After making that change, make a backup copy of Apache's configuration, rebuild it and restart it:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110303
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    If you then check grep for webmail in the file, it shouldn't return anything in the file any longer:

    Code:
    grep -i webmail /usr/local/apache/conf/httpd.conf
    Of note, by changing the main.default file to main.local, you are bypassing the cPanel updates for main.default happening any longer. Your Apache will begin only using the template main.local you have. This means that if we drastically modify main.default at some point in the future, your Apache configuration file will be out of date. This is something to keep in mind when changing the templates such as this would do.
     
    Samet Chan likes this.
  3. jspierre

    jspierre Member

    Joined:
    Mar 3, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Awesome! Thanks!
     
Loading...

Share This Page