I have installed OpenCart in a subdirectory (ex: www.example.com/shop/) but I would like to move/show the OpenCart front page as my main website front page.
Can it be done, please?
Try this
RedirectMatch 301 ^/shop/$ http://www.example.com/
in your htaccess file
#This is a permanent redirect
RedirectMatch 301 ^/shop/.*$ http://www.example.com/
#This is a temporary redirect
RedirectMatch 302 ^/shop/.*$ http://www.example.com/
You will have to change the paths in 2 config.php files. First, the config.php file from main Opencart directory and the second config.php file from admin folder.
Example:
from this:
<?php
// HTTP
define('HTTP_SERVER', 'http://www.example.com/shop/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/shop/');
// DIR
define('DIR_APPLICATION', '/home/user/opencart/shop/catalog/');
define('DIR_SYSTEM', '/home/user/opencart/shop/system/');
define('DIR_DATABASE', '/home/user/opencart/shop/system/database/');
define('DIR_LANGUAGE', '/home/user/opencart/shop/catalog/language/');
define('DIR_TEMPLATE', '/home/user/opencart/shop/catalog/view/theme/');
define('DIR_CONFIG', '/home/user/opencart/shop/system/config/');
define('DIR_IMAGE', '/home/user/opencart/shop/image/');
define('DIR_CACHE', '/home/user/opencart/shop/system/cache/');
define('DIR_DOWNLOAD', '/home/user/opencart/shop/download/');
define('DIR_LOGS', '/home/user/opencart/shop/system/logs/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'opencart');
define('DB_PREFIX', 'oc_');
?>
to this:
<?php
// HTTP
define('HTTP_SERVER', 'http://www.example.com/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/');
// DIR
define('DIR_APPLICATION', '/home/user/opencart/catalog/');
define('DIR_SYSTEM', '/home/user/opencart/system/');
define('DIR_DATABASE', '/home/user/opencart/system/database/');
define('DIR_LANGUAGE', '/home/user/opencart/catalog/language/');
define('DIR_TEMPLATE', '/home/user/opencart/catalog/view/theme/');
define('DIR_CONFIG', '/home/user/opencart/system/config/');
define('DIR_IMAGE', '/home/user/opencart/image/');
define('DIR_CACHE', '/home/user/opencart/system/cache/');
define('DIR_DOWNLOAD', '/home/user/opencart/download/');
define('DIR_LOGS', '/home/user/opencart/system/logs/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'opencart');
define('DB_PREFIX', 'oc_');
?>
Where /home/user/opencart/ is the fullpath of Opencart installation.
And notice I removed /shop from each path.
Also, if you have a .htaccess file, you will have to change the RewriteBase:
from
RewriteBase /shop/
to
RewriteBase /
Related
I've got OpenCart VERSION', '3.0.3.8 and tried to change the image folder with unexpected results.
my config.php modified with following update
define('HTTP_SERVER', 'http://example.com/opencart/');
// HTTPS
define('HTTPS_SERVER', 'https://example.com/opencart/');
// DIR
define('DIR_APPLICATION', '/home/example/public_html/opencart/catalog/');
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/catalog/language/');
define('DIR_TEMPLATE', '/home/example/public_html/opencart/catalog/view/theme/');
define('DIR_CONFIG', '/home/example/public_html/opencart/system/config/');
define('DIR_IMAGE', '/home/example/public_html/opencart/newimagefolder/');
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/');
After this modification I can't able to show my image from domain. its point to old image directory
<img src="https://example.com/image/cache/catalog/DRESS/12-550x550.jpg" srcset="https://example.com/image/cache/catalog/DRESS/12-550x550.jpg 1x, https://example.com/image/cache/catalog/DRESS/12-1100x1100.jpg 2x" data-largeimg="https://example.com/image/cache/catalog/DRESS/12-1000x1000.jpg" alt="Dichus Shirt" title="Dichus Shirt" width="550" height="550">
Have you cleared your cache?
Have you moved your open cart installation into a sub folder?
Have you set this folder up in the htaccess
Your config.php doesn't seem to be opencart V3.0.3.8. You would typically have a storage define('DIR_CACHE', DIR_STORAGE .
I have an issue with OC3:
When I open admin page i has only white page. When I open error log I have anything, all is okay but page doesnt open.
My config file:
<?php
// HTTP
define('HTTP_SERVER', 'http://nanox.md/admin');
define('HTTP_CATALOG', 'http://nanox.md/');
// HTTPS
define('HTTPS_SERVER', 'http://nanox.md/admin');
define('HTTPS_CATALOG', 'http://nanox.md/');
// DIR
define('DIR_APPLICATION', '/home/bodybuilding/public_html/nanox/catalog/admin');
define('DIR_SYSTEM', '/home/bodybuilding/public_html/nanox/system/');
define('DIR_IMAGE', '/home/bodybuilding/public_html/nanox/image/');
define('DIR_STORAGE', DIR_SYSTEM . 'storage/');
define('DIR_LANGUAGE', DIR_APPLICATION . 'language/');
define('DIR_CATALOG', '/home/bodybuilding/public_html/nanox/catalog/');
define('DIR_TEMPLATE', DIR_APPLICATION . 'view/theme/');
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/');
// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '*');
define('DB_PASSWORD', '*');
define('DB_DATABASE', '*');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
And link to the admin page is http://nanox.md/admin
Please help :)
Your admin folder is not on catalog folder so replace this:
define('DIR_APPLICATION', '/home/bodybuilding/public_html/nanox/catalog/admin');
with this
define('DIR_APPLICATION', '/home/bodybuilding/public_html/nanox/admin');
You seem to have missed the last "/" in your Application definition, additionally, your path is incorrect, there is no admin folder in the catalog, try replacing this:
define('DIR_APPLICATION', '/home/bodybuilding/public_html/nanox/catalog/admin');
with this:
define('DIR_APPLICATION', '/home/bodybuilding/public_html/nanox/admin/');
I have a novice question that you can help me easily. I have installed OC in root. I want to move it to a subfolder in the root. For example,if I have www.mysite.com, I want to move it in www.mysite.com/Subfolder. I have redirected www.mysite.com to www.mysite.com/Subfolder through htaccess in the root. What changes I need to make to config.php and admin/config.php and to htaccess in the Subfolder. Would I need to make changes to other files too in the Subfolder? How to deal with databases in www.mysite.com? Where I need to export it? How can I achieve this? I am using OC 3.0.2.0. I would be thankful for any help. My Subfolder config.php looks like this
define('HTTP_SERVER', 'http://www.example.com/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/catalog/');
define('DIR_SYSTEM', '/home/user/public_html/system/');
define('DIR_IMAGE', '/home/user/public_html/image/');
define('DIR_STORAGE', '/home/user/storedata1/storage/');
define('DIR_LANGUAGE', DIR_APPLICATION . 'language/');
define('DIR_TEMPLATE', DIR_APPLICATION . 'view/theme/');
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/');
and my Subfolder admin config.php looks like this
// HTTP
define('HTTP_SERVER', 'http://www.example.com/admin/');
define('HTTP_CATALOG', 'http://www.example.com/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/admin/');
define('HTTPS_CATALOG', 'http://www.example.com/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/admin/');
define('DIR_SYSTEM', '/home/user/public_html/system/');
define('DIR_IMAGE', '/home/user/public_html/image/');
define('DIR_STORAGE', '/home/user/storedata1/storage/');
define('DIR_CATALOG', '/home/user/public_html/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/');
Please advise me how to edit my Subfolder config.php and Subfolder/admin/config.php and in which places I need to put my Subfolder
There are three places you'll need to make the edits:
OpenCartSiteFolder/config.php
OpenCartSiteFolder/admin/config.php
Update .htaccess file
Step 1. You must modify the paths in the config.php to match the name of the new folder you're placing the site into (assuming you're hosting on linux shared hosting):
// HTTP
define('HTTP_SERVER', 'http://www.website.com/subfolder_name/');
// HTTPS
define('HTTPS_SERVER', 'https://www.website.com/subfolder_name/');
// DIR
define('DIR_APPLICATION', '/usr/www/users/ftp_username/subfolder_name/catalog/');
define('DIR_SYSTEM', '/usr/www/users/ftp_username/subfolder_name/system/');
define('DIR_IMAGE', '/usr/www/users/ftp_username/subfolder_name/image/');
define('DIR_LANGUAGE', '/usr/www/users/ftp_username/subfolder_name/catalog/language/');
define('DIR_TEMPLATE', '/usr/www/users/ftp_username/subfolder_name/catalog/view/theme/');
define('DIR_CONFIG', '/usr/www/users/ftp_username/subfolder_name/system/config/');
define('DIR_CACHE', '/usr/www/users/ftp_username/subfolder_name/system/storage/cache/');
define('DIR_DOWNLOAD', '/usr/www/users/ftp_username/subfolder_name/system/storage/download/');
define('DIR_LOGS', '/usr/www/users/ftp_username/subfolder_name/system/storage/logs/');
define('DIR_MODIFICATION', '/usr/www/users/ftp_username/subfolder_name/system/storage/modification/');
define('DIR_UPLOAD', '/usr/www/users/ftp_username/subfolder_name/system/storage/upload/');
Step 2: You must modify the paths in the website/sub_folder/admin/config.php to match the name of the new folder you're placing the site into:
// HTTP
define('HTTP_SERVER', 'http://www.website.com/subfolder_name/');
// HTTPS
define('HTTPS_SERVER', 'https://www.website.com/subfolder_name/');
// HTTP
define('HTTP_SERVER', 'http://www.website.com/subfolder_name/admin/');
define('HTTP_CATALOG', 'http://www.website.com/subfolder_name/');
// HTTPS
define('HTTPS_SERVER', 'https://www.website.com/subfolder_name/admin/');
define('HTTPS_CATALOG', 'https://www.website.com/subfolder_name/');
// DIR
define('DIR_APPLICATION', '/usr/www/users/ftp_username/subfolder_name/admin/');
define('DIR_SYSTEM', '/usr/www/users/ftp_username/subfolder_name/system/');
define('DIR_IMAGE', '/usr/www/users/ftp_username/subfolder_name/image/');
define('DIR_LANGUAGE', '/usr/www/users/ftp_username/subfolder_name/admin/language/');
define('DIR_TEMPLATE', '/usr/www/users/ftp_username/subfolder_name/admin/view/template/');
define('DIR_CONFIG', '/usr/www/users/ftp_username/subfolder_name/system/config/');
define('DIR_CACHE', '/usr/www/users/ftp_username/subfolder_name/system/storage/cache/');
define('DIR_DOWNLOAD', '/usr/www/users/ftp_username/subfolder_name/system/storage/download/');
define('DIR_LOGS', '/usr/www/users/ftp_username/subfolder_name/system/storage/logs/');
define('DIR_MODIFICATION', '/usr/www/users/ftp_username/subfolder_name/system/storage/modification/');
define('DIR_UPLOAD', '/usr/www/users/ftp_username/subfolder_name/system/storage/upload/');
define('DIR_CATALOG', '/usr/www/users/ftp_username/subfolder_name/catalog/');
You may also need to update your htaccess file as K.B. mentioned:
RewriteBase /subfolder_name/
config.php
define('HTTP_SERVER', 'http://www.example.com/subfolder_name/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/subfolder_name/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/subfolder_name/catalog/');
define('DIR_SYSTEM', '/home/user/public_html/subfolder_name/system/');
define('DIR_IMAGE', '/home/user/public_html/subfolder_name/image/');
define('DIR_STORAGE', '/home/user/storedata1/storage/');
define('DIR_LANGUAGE', DIR_APPLICATION . 'language/');
define('DIR_TEMPLATE', DIR_APPLICATION . 'view/theme/');
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/');
Subfolder admin config.php should be:
// HTTP
define('HTTP_SERVER', 'http://www.example.com/subfolder_name/admin/');
define('HTTP_CATALOG', 'http://www.example.com/subfolder_name/');
// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/subfolder_name/admin/');
define('HTTPS_CATALOG', 'http://www.example.com/subfolder_name/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/subfolder_name/admin/');
define('DIR_SYSTEM', '/home/user/public_html/subfolder_name/system/');
define('DIR_IMAGE', '/home/user/public_html/subfolder_name/image/');
define('DIR_STORAGE', '/home/user/storedata1/storage/');
define('DIR_CATALOG', '/home/user/public_html/subfolder_name/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/');
I have installed open cart on my demo subdomain server.
config file changed by me is as follows
// HTTP
define('HTTP_SERVER', 'https://demos.abc.com/artnkraft/');
// HTTPS
define('HTTPS_SERVER', 'https://demos.abc.com/artnkraft/');
// DIR
define('DIR_APPLICATION', '/demos/artnkraft/catalog/');
define('DIR_SYSTEM', '/demos/artnkraft/system/');
define('DIR_IMAGE', '/demos/artnkraft/image/');
define('DIR_LANGUAGE', '/demos/artnkraft/catalog/language/');
define('DIR_TEMPLATE', '/demos/artnkraft/catalog/view/theme/');
define('DIR_CONFIG', '/demos/artnkraft/system/config/');
define('DIR_CACHE', '/demos/artnkraft/system/storage/cache/');
define('DIR_DOWNLOAD', '/demos/artnkraft/system/storage/download/');
define('DIR_LOGS', '/demos/artnkraft/system/storage/logs/');
define('DIR_MODIFICATION', '/demos/artnkraft/system/storage/modification/');
define('DIR_UPLOAD', '/demos/artnkraft/system/storage/upload/');
// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'abc');
define('DB_PASSWORD', 'abc#_password');
define('DB_DATABASE', 'abc_database');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
this gives error
Warning: require_once(/demos/artnkraft/system/startup.php): failed to open stream: No such file or directory in /home/cloudusweb/public_html/demos/artnkraft/index.php on line 17
Fatal error: require_once(): Failed opening required '/demos/artnkraft/system/startup.php' (include_path='.:/usr/local/lib/php') in /home/cloudusweb/public_html/demos/artnkraft/index.php on line 17
i have also change the admin config file.
help me how to configure configre file to correct path
thanks in advance
I have a Django project and I wanna delivery it using gunicorn (and apache proxing).
I can't use Nginx, so that's no possible.
I've set the Apache proxy and setup a runner script to gunicorn, but i am get this weird error
2012-08-27 14:03:12 [34355] [DEBUG] GET /
2012-08-27 14:03:12 [34355] [ERROR] Error handling request
Traceback (most recent call last):
File "/home/tileone/venv/lib/python2.6/site-packages/gunicorn/workers/sync.py", line 93, in handle_request
self.address, self.cfg)
File "/home/tileone/venv/lib/python2.6/site-packages/gunicorn/http/wsgi.py", line 146, in create
path_info = path_info.split(script_name, 1)[1]
IndexError: list index out of range
I am running this script
#!/bin/bash
LOGFILE=/var/log/gunicorn/one-project.log
VENV_DIR=/path/to/venv/
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=5
# user/group to run as
USER=USER
GROUP=GROUP
BIND=127.0.0.1:9999
cd /path_to_project
echo 'Setup Enviroment'
#some libraries
echo 'Setup Venv'
source $VENV_DIR/bin/activate
export PYTHONPATH=$VENV_DIR/lib/python2.6/site-packages:$PYTHONPATH
#Setup Django Deploy
export DJANGO_DEPLOY_ENV=stage
echo 'Run Server'
test -d $LOGDIR || mkdir -p $LOGDIR
export SCRIPT_NAME='/home/tileone/one-project'
exec $VENV_DIR/bin/gunicorn_django -w $NUM_WORKERS --bind=$BIND\
--user=$USER --group=$GROUP --log-level=debug \
--log-file=$LOGFILE 2>>$LOGFILE
and my apache configuration is like this:
Alias /static/ /hpath_to_static/static/
Alias /media/ /path_to_static/media/
Alias /favicon.ico /path_to/favicon.ico
ProxyPreserveHost On
<Location />
SSLRequireSSL
ProxyPass http://127.0.0.1:9999/
ProxyPassReverse http://127.0.0.1:9999/
RequestHeader set SCRIPT_NAME /home/tileone/one-project/
RequestHeader set X-FORWARDED-PROTOCOL ssl
RequestHeader set X-FORWARDED-SSL on
</Location>
What am i doing wrong?
In case anyone has similar issues, I managed to fix this by removing the equivalent of:
RequestHeader set SCRIPT_NAME /home/tileone/one-project/
And instead adding to settings.py the equivalent of:
FORCE_SCRIPT_NAME = '/one-project'
Of course for this, the apache configuration should be more like:
ProxyPreserveHost On
<Location /one-project/>
SSLRequireSSL
ProxyPass http://127.0.0.1:9999/
ProxyPassReverse http://127.0.0.1:9999/
RequestHeader set X-FORWARDED-PROTOCOL ssl
RequestHeader set X-FORWARDED-SSL on
</Location>
The reason for the fix proposed in the accepted answer is that you need to decide between one of the following two approaches:
Let the HTTP server strip the location sub path BEFORE forwarding the request to the WSGI server (as explained above ... this is done when both the Location and the ProxyPass directive end with a forward slash. Nginx behaves the same way). In this case, you may not use the SCRIPT_NAME HTTP header/gunicorn-env-variable, because gunicorn would try to strip the value from the incoming URL (but that fails because the web server, Apache, already did that). In this case, you're forced to use Django's FORCE_SCRIPT_NAME setting.
Let the request URL passed to gunicorn unmodified (an example of an URL might be /one-project/admin), and use the SCRIPT_NAME HTTP header (or gunicorn-env-variable). Because then gunicorn will modify the request and strip the value of SCRIPT_NAME from the URL before Django handles building the response.
I would prefer option 2, because you only need to change one file, the web server configuration, and all changes are neatly together.