Do you want to remove the default /admin/ in OpenCart and reduce junk login attempts? We’ll explain in simple terms two ways to change the admin URL - renaming the folder or using a “virtual” URL via rewrite, with ready-made rules for Apache and Nginx.
→Best-selling templates and extensions in July 2025: Microdata, ChatGPT, Server Video, Mango template
→New in July 2025: Remember Me, Quick Social Login, Smart Recommendations
→The Simple module is one of the most popular modules for simplifying checkout and registration in OpenCart 3. However, after its installation, a critical error may occur related to an outdated modification of the Twig template engine.
→
By default, the OpenCart admin panel is located at /admin/
. This is well-known to attackers and various bots. Changing or hiding this URL is a simple way to reduce junk in your logs and brute-force attempts. Below are two clear options for OpenCart 1.5 / 2.x / 3.x (including ocStore 3.0.3.9): rename the folder or set up a “virtual” URL via web server rules.
/var/www/site/
) and the domain (https://example.com
).DIR_STORAGE
(often placed outside the site root).admin
folderadmin
– for example, to secret-admin
.admin/config.php
with the new URL and correct paths.
// HTTP
define('HTTP_SERVER', 'https://example.com/secret-admin/');
// HTTPS
define('HTTPS\_SERVER', '[https://example.com/secret-admin/](https://example.com/secret-admin/)');
// DIR
define('DIR\_APPLICATION', '/var/www/site/secret-admin/');
define('DIR\_SYSTEM', '/var/www/site/system/');
define('DIR\_IMAGE', '/var/www/site/image/');
define('DIR\_STORAGE', '/var/www/site/system/storage/'); // or external path
define('DIR\_CATALOG', '/var/www/site/catalog/');
define('DIR\_LANGUAGE', DIR\_APPLICATION . 'language/');
define('DIR\_TEMPLATE', DIR\_APPLICATION . 'view/template/');
define('DIR\_CONFIG', DIR\_SYSTEM . 'config/');
define('DIR\_CACHE', DIR\_STORAGE . 'cache/');
define('DIR\_DOWNLOAD', DIR\_STORAGE . 'download/');
define('DIR\_LOGS', DIR\_STORAGE . 'logs/');
define('DIR\_MODIFICATION', DIR\_STORAGE . 'modification/');
define('DIR\_SESSION', DIR\_STORAGE . 'session/');
define('DIR\_UPLOAD', DIR\_STORAGE . 'upload/');
// HTTP/HTTPS
define('HTTP_SERVER', 'https://example.com/secret-admin/');
define('HTTPS_SERVER', 'https://example.com/secret-admin/');
// DIR
define('DIR\_APPLICATION', '/var/www/site/secret-admin/');
define('DIR\_SYSTEM', '/var/www/site/system/');
define('DIR\_IMAGE', '/var/www/site/image/');
define('DIR\_CATALOG', '/var/www/site/catalog/');
define('DIR\_LANGUAGE', DIR\_APPLICATION . 'language/');
define('DIR\_TEMPLATE', DIR\_APPLICATION . 'view/template/');
define('DIR\_CONFIG', DIR\_SYSTEM . 'config/');
// Other DIR\_\* — depending on your build (often inside system/storage)
// HTTP
define('HTTP_SERVER', 'https://example.com/secret-admin/');
// Front:
define('HTTP_CATALOG', 'https://example.com/');
// DIR
define('DIR\_APPLICATION', '/var/www/site/secret-admin/');
define('DIR\_SYSTEM', '/var/www/site/system/');
define('DIR\_IMAGE', '/var/www/site/image/');
define('DIR\_CATALOG', '/var/www/site/catalog/');
After editing, clear caches (in 2.x/3.x: “Extensions – Modifications – Refresh”; if admin is unavailable – manually delete system/storage/cache
and system/storage/modification
) and test login with the new address.
Pros: works “out of the box”, OpenCart/ocStore generates correct links.
Cons: you must remember the new folder name and set paths carefully.
The idea: the folder remains /admin/
, but externally you log in via /cp/
. This requires changing the visible HTTP_SERVER
and adding web server rules.
admin
directory as is.admin/config.php
set the “visible” URL:
// Visible addresses
define('HTTP_SERVER', 'https://example.com/cp/');
define('HTTPS_SERVER', 'https://example.com/cp/');
// Physical paths — to actual admin folder
define('DIR\_APPLICATION', '/var/www/site/admin/');
RewriteEngine On
# Serve /cp/ from physical /admin/
RewriteRule ^cp(/.\*)?\$ admin\$1 \[L]
# (Optional) Block direct /admin/
RewriteRule ^admin(/.\*)?\$ - \[R=404,L]
# Visible URL
location ^~ /cp/ {
rewrite ^/cp/(.*)$ /admin/$1 last;
}
# (Optional) Block direct /admin/
location ^\~ /admin/ {
return 404;
}
Restart the web server, clear OpenCart caches – and access via /cp/
.
Pros: no changes to file structure.
Cons: must configure rules correctly to avoid breaking existing redirects.
Add to the start of /admin/.htaccess:
Order deny,allow
deny from all
Allow from 1.1.1.1
where 1.1.1.1
is your IP address.
admin
and disable unused accounts.HTTP_SERVER
/HTTPS_SERVER
: must be /cp/
, not /cp
.DIR_*
paths: check the real site path.RewriteRule
and location
matters.http://
– leads to extra redirects and warnings.admin/config.php
.HTTP_SERVER
back to /admin/
.