skip to Main Content

I have a severe problem, my cPanel URLs public, I don’t want anyone to know the cPanel configuration URLs because if any user can access it with yourdomain.com/cpanel.

As I have shared hosting, I don’t have access to the httpd/root or the server configuration files. I want to know whether I can add some code to the .htaccess file and stop this redirection.

2

Answers


  1. If you want to deny access to http://www.example.com/cpanel, do this:

    • In httpd.conf make sure you load mod_rewrite: LoadModule rewrite_module modules/mod_rewrite.so. Since you are on a shared hosting, you may not have access to that, but then it is most probably already loaded.
    • In your .htaccess, add:

      RewriteEngine On
      RewriteCond %{QUERY_STRING} "^/cpanel$"
      RewriteRule ".*" "-" [F,L]
      
    • Tag [F] causes the server to return a 403 Forbidden status code to the client (ref: https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_f)

    To ensure the .htaccess directives are taken into account, make sure you add this to the options of the directory where it resides:

    AllowOverwride All
    

    Refer to this SO question: How to Set AllowOverride all

    Login or Signup to reply.
  2. I previously had shared hosting, and I discovered that this is not possible in shared hosting, you need to have root access.
    I bought a vps hosting and removed it by doing the following:

    1. Copying the Apache 2.4 template for EasyApache 4 to allow for customization using command line/terminal:
    cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
    
    1. By editing /var/cpanel/templates/apache2_4/ea4_main.local to change the entries to match your preferences:
    vim /var/cpanel/templates/apache2_4/ea4_main.local
    
    1. For instance, if you wanted to disable the /cpanel alias, you’d remove this line when editing the file:
    ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
    
    1. And then rebuilding the httpd.conf file by using:
    /scripts/rebuildhttpdconf
    
    1. And the last step is to restart by using:
    service httpd restart
    

    And your cPanel conf paths will be removed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search