How to configure Opencart Live site Dynamically?

旧城冷巷雨未停 提交于 2019-12-10 10:35:30

问题


I have an opencart site, which is moved from Local server to Live. How to configure the site path in config.php file


回答1:


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/');


来源:https://stackoverflow.com/questions/24851890/how-to-configure-opencart-live-site-dynamically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!