How to rename admin folder name in OpenCart 1.5 & vQmod?

To make it a little more difficult for hackers to attack your OpenCart Dashboard & Admin area, changing the admin folder URL is a basic security practice. Learn how to rename admin folder url to prevent unwanted hack attempts from discovering the login page and other resources.

Once you follow the steps below to rename the admin folder name to for eg. “rocketscience”, your OpenCart store will be accessible at www.example.com/rocketscience instead of www.example.com/admin

Steps to Change OpenCart 1.5 Admin Dashboard URL



Log into your hosting account cPanel, or FTP
Navigate to the folder containing the admin folder. It is usually the public_html or /var/www/html folders.
Right click on the admin folder and choose the rename option from the dropdown
Enter the new folder name for the admin folder. Use an un-common name which is hard to guess and completely unrelated to your business.  (For eg: “STA22R1”, “ROCKETSCIENCE74851”)
Now, edit the /admin/config.php and replace ALL instances of the word ‘admin’ with the new folder name you have chosen in the above step.

// HTTP
    define('HTTP_SERVER', 'https://www.example.com/opencart/admin/');
    define('HTTP_CATALOG', 'https://www.example.com/opencart/');
    
    // HTTPS
    define('HTTPS_SERVER', 'https://www.example.com/opencart/**admin**/');
    define('HTTPS_CATALOG', 'https://www.example.com/opencart/');
    
    // DIR
    define('DIR_APPLICATION', '/home/example/public_html/opencart/admin/');
    define('DIR_SYSTEM', '/home/example/public_html/opencart/system/');
    define('DIR_DATABASE', '/home/example/public_html/opencart/system/database/');
    define('DIR_LANGUAGE', '/home/example/public_html/opencart/admin/language/');
    define('DIR_TEMPLATE', '/home/example/public_html/opencart/admin/view/template/');
    define('DIR_CONFIG', '/home/example/public_html/opencart/system/config/');
    define('DIR_IMAGE', '/home/example/public_html/opencart/image/');
    define('DIR_CACHE', '/home/example/public_html/opencart/system/cache/');
    define('DIR_DOWNLOAD', '/home/example/public_html/opencart/download/');
    define('DIR_LOGS', '/home/example/public_html/opencart/system/logs/');
    define('DIR_CATALOG', '/home/example/public_html/opencart/catalog/');
    
    // DB
    define('DB_DRIVER', 'mysql');
    define('DB_HOSTNAME', 'localhost');
    define('DB_USERNAME', 'username_example');
    define('DB_PASSWORD', 'password');
    define('DB_DATABASE', 'username_example');
    define('DB_PREFIX', 'oc_');

If you are using vQmod, you will have to update the pathReplaces.php file, located in the /vqmod directory. The code to rename the ‘admin’ folder should already be there. It would be similar to the code shown below:
// START REPLACES //
        $replaces[] = array('~^admin\b~', 'backend'); // This replaces the admin directory name to backend in all VQMod xmls automatically
        // END REPLACES //


Replace the word backend with the new folder name we have chosen in the above steps.

Updated on: 18/07/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!