SOLVED Remove domain.com/cPanel & WHM URL

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello,

The instructions in the links you provided were intended for systems using EasyApache 3. With EasyApache 4, you'd have to follow the instructions below:

1. Copy the Apache 2.4 template for EasyApache 4 to allow for customization:

Code:
cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
2. Edit /var/cpanel/templates/apache2_4/ea4_main.local to change the entries to match your preferences:

Code:
vi /var/cpanel/templates/apache2_4/ea4_main.local
For instance, if you wanted to disable the /cpanel alias, you'd remove this line when editing the file:

Code:
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
3. Rebuild the Apache configuration file:

Code:
/scripts/rebuildhttpdconf
Keep in mind the ".local" template takes precedence over the ".default" template. You will have to manually update the ".local" template every time a new default template is issued. As of cPanel 64.0.19, notifications are sent when the EA4 default templates are updated and a local template file exists:

Fixed case CPANEL-12933: Notify admins of EA4 template changes if .local versions exist.

Thank you.
 
  • Like
Reactions: Sametto Chan

Samet Chan

Well-Known Member
Jun 24, 2016
369
42
153
cPanel Access Level
Root Administrator
Twitter
Thank you!

I'm on EA4 and v66.0.14 current version.

1,2 number question. Is it on SSH for root access right? Or SFTP.

Answer another my two question,

2.
Code:
cp -a /var/cpanel/templates/apache2_4/ea4_main.default
[root@x ~]# cp -a /var/cpanel/templates/apache2_4/ea4_main.default
cp: missing destination file operand after ‘/var/cpanel/templates/apache2_4/ea4_main.default’
Try 'cp --help' for more information.
Looks like are not working command line.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
1,2 number question. Is it on SSH for root access right? Or SFTP.
You'd use SSH as "root" with these instructions.

Looks like are not working command line.
That's not the full command referenced in my response. It's:

Code:
cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
Thank you.
 
  • Like
Reactions: Sametto Chan

Samet Chan

Well-Known Member
Jun 24, 2016
369
42
153
cPanel Access Level
Root Administrator
Twitter
Code:
<IfModule alias_module>
    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
[% IF autodiscover_proxy_subdomains -%]
    ScriptAliasMatch ^/Autodiscover/Autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
    ScriptAliasMatch ^/autodiscover/autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
[% END -%]

    Alias /bandwidth /usr/local/bandmin/htdocs/
    Alias /img-sys /usr/local/cpanel/img-sys/
    Alias /java-sys /usr/local/cpanel/java-sys/
    Alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/
    Alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/
    Alias /sys_cpanel /usr/local/cpanel/sys_cpanel/

    ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/
    ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/
    [% IF file_test('f', '/usr/local/cpanel/cgi-sys/scgiwrap') %]ScriptAlias /scgi-bin /usr/local/cpanel/cgi-sys/scgiwrap[% END %]
</IfModule>
1. Can I remove WHM and cPanel, Webmail?

2. But What about kPanel?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello,

You can remove any of those "ScriptAliasMatch" if you want to disable the use of those aliases.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
I can't enter "Backspace" remove of lines in SSH for vi, Possible for nano?
You can use the text editor of your preference (e.g. nano, vim).

Also, Can I remove autodiscover Proxy_domains too?
Yes, but keep in mind that will prevent the use of the autodiscover subdomain.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
New Alright, Also I'll use SFTP to edit that file? Or just only on SSH nano?
Yes, you could download the file via SFTP, edit it, and then upload the new copy.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
I checked site.com/cpanel and whm still up.
Try clearing your browser cache or testing from another browser to make sure you are not visiting a cached URL.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Doesn't work. I removed lines then restarted httpd.conf say OK. I checked site.com/cpanel and whm still up.
This is working well on a test server. It's possible you made some incorrect changes to the ea4_main.local file. Could you open the /var/cpanel/templates/apache2_4/ea4_main.local file on the server using the "vi" command? EX:

Code:
vi /var/cpanel/templates/apache2_4/ea4_main.local
Does it look formatted correctly? You will sometimes face encoding issues when editing a file on a Windows-based machine and then uploading it directly via SFTP.

Thank you.
 

Samet Chan

Well-Known Member
Jun 24, 2016
369
42
153
cPanel Access Level
Root Administrator
Twitter
This is working well on a test server. It's possible you made some incorrect changes to the ea4_main.local file. Could you open the /var/cpanel/templates/apache2_4/ea4_main.local file on the server using the "vi" command? EX:

Code:
vi /var/cpanel/templates/apache2_4/ea4_main.local
Does it look formatted correctly? You will sometimes face encoding issues when editing a file on a Windows-based machine and then uploading it directly via SFTP.

Thank you.
I did just nano from SSH has saved file then httpd.conf is restarted but nothing.
Screenshot_1.png
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Feel free to open a support ticket using the link in my signature if you'd like us to take a closer look to see why it's not working.

Thank you.
 

Samet Chan

Well-Known Member
Jun 24, 2016
369
42
153
cPanel Access Level
Root Administrator
Twitter
It is fixed! Thanks to cPanel support!

Michael B said:
Hello,

1.
It looks like CloudFlare may have been caching the cPanel redirect. I temporarily stopped Apache to force CloudFlare to update which page it loads when you access /cpanel and after clearing my browser cache I am no longer being redirected to the cPanel login page when loading "http://site.com/cpanel."

I have attached screenshots of what I am seeing on my end. Could you try clearing your browser cache and or using an alternate browser that has not visted the above URL to see if you are still being redirected. If you are still being redirected please try enabling CloudFlare's developer mode which disabled caching and see if that resolves your issue.

Regards,

--
Michael B.
Linux Technical Analyst
cPanel, Inc.

Join us for the 2017 cPanel Conference!
Sept. 26th & 27th in Fort Lauderdale, Fl.
cPanel Conference | cPanel & WHM

2.
There are no rewrites to handle the "/whm" script alias match in Apache's configuration and I'm not able to replicate the page still redirecting to WHM's login page as seen in my provided screenshot:

=====
# grep -i scriptalias !$
grep -i scriptalias /etc/apache2/conf/httpd.conf
ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/
ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/
=====

I suspect you are still cached in some way on your end. Could you try loading the WHM URL on another device?

3.
I would recommend keeping the "/cgi-sys" script alias match as that directory contains a number of cPanel CGI scripts such as the suspended account page and the default error page for misconfigured domains.
Sametto Chan said:
1.
Please visit this: Remove domain.com/cPanel & WHM URL

2.
Thank you very much helpfully!!

It worked now. I use from chrome incognito.

But, what is about cgi-sys?

ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/

3.
Okay, Thanks for the info. You can solve this support ticket. And I will update on thread too.
 
  • Like
Reactions: cPanelMichael