Reputation: 53
I have an opencart site, which is moved from Local server to Live. How to configure the site path in config.php file
Upvotes: 2
Views: 2022
Reputation: 133
This is a slight modification we make to Opencart config file to save us time and effort when moving store from development to live server with different paths.
Change config.php files with this code
// HTTP
define('HTTP', $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/');
define('HTTP_SERVER', 'http://'.HTTP);
define('HTTP_IMAGE', 'http://'.HTTP.'image/');
define('HTTP_ADMIN', 'http://'.HTTP.'admin/');
// HTTPS
define('HTTPS_SERVER', 'http://'.HTTP);
define('HTTPS_IMAGE', 'http://'.HTTP.'image/');
// DIR
define('BASE_DIR', realpath(dirname(__FILE__)));
define('DIR_APPLICATION', BASE_DIR.'/catalog/');
define('DIR_SYSTEM', BASE_DIR.'/system/');
define('DIR_DATABASE', BASE_DIR.'/system/database/');
define('DIR_LANGUAGE', BASE_DIR.'/catalog/language/');
define('DIR_TEMPLATE', BASE_DIR.'/catalog/view/theme/');
define('DIR_CONFIG', BASE_DIR.'/system/config/');
define('DIR_IMAGE', BASE_DIR.'/image/');
define('DIR_CACHE', BASE_DIR.'/system/cache/');
define('DIR_DOWNLOAD', BASE_DIR.'/download/');
define('DIR_LOGS', BASE_DIR.'/system/logs/');
Change admin/config.php file with this code
// HTTP
define('HTTP', $_SERVER['HTTP_HOST'].str_replace('/admin','',dirname($_SERVER['PHP_SELF'])));
define('HTTP_SERVER', 'http://'.HTTP.'/admin/');
define('HTTP_CATALOG', 'http://'.HTTP.'/');
define('HTTP_IMAGE', 'http://'.HTTP.'/image/');
// HTTPS
define('HTTPS_SERVER', 'http://'.HTTP.'/admin/');
define('HTTPS_IMAGE', 'http://'.HTTP.'/image/');
// DIR
define('BASE_DIR', str_replace(DIRECTORY_SEPARATOR.'admin', '', realpath(dirname(__FILE__))));
define('DIR_APPLICATION', BASE_DIR.'/admin/');
define('DIR_SYSTEM', BASE_DIR.'/system/');
define('DIR_DATABASE', BASE_DIR.'/system/database/');
define('DIR_LANGUAGE', BASE_DIR.'/admin/language/');
define('DIR_TEMPLATE', BASE_DIR.'/admin/view/template/');
define('DIR_CONFIG', BASE_DIR.'/system/config/');
define('DIR_IMAGE', BASE_DIR.'/image/');
define('DIR_CACHE', BASE_DIR.'/system/cache/');
define('DIR_DOWNLOAD', BASE_DIR.'/download/');
define('DIR_LOGS', BASE_DIR.'/system/logs/');
define('DIR_CATALOG', BASE_DIR.'/catalog/');
Upvotes: 7