2.14.3.24. Move storage directory outside OpenCart root directory

Attention!

Backups of the site on the hosting do not include directories that are outside the root directory. Such directories will only be available in the backup of the entire hosting account.

In OpenCart, to ensure greater security for site files, the storage directory can be moved outside the site root directory. This is done so that the directory cannot be accessed via HTTP.

This transfer can be performed automatically or manually.

Conditions for automatic transfer:

  • The storage directory is located in the site root directory.
  • OpenCart version 3.0.3.0 or higher is used.
  • No changes were made to the OpenCart settings.
  • Moving the storage directory using the CMS itself. In this regard, there may be additional conditions for its correct operation.

To automatically transfer the storage directory, do the following:

  1. In the sidebar, go to the "Dasboard" section:
  2. If all conditions are met, a window will appear with a suggestion to move the storage directory outside the site directory. To move the directory, click "Move":
To move the storage directory outside the site root directory, do the following:
  1. Using the file manager or any FTP client, move the storage directory from site root directory to the level above — to the directory with the name of the main domain (so that it is accessible via the path example.com/storage/, where example.com is the name of the main domain).
  2. Edit the OpenCart configuration files or use universal configuration files by changing the line:
    define('DIR_STORAGE', DIR_SYSTEM . 'storage/');

    To the following:

    define('DIR_STORAGE', '/home/user/example.com/' . 'storage/');

    Instead of user, specify the name of your hosting account, and instead of example.com, specify the name of the main domain without subdomains.

Content