Page 1 of 2

Relative vs absolute paths

Posted: Wed Jan 27, 2016 7:01 am
by geotnt
I'm in the process of upgrading my wife's site from zencart to opencart 2.0. To allow her zencart site to work while she's uploading products to the opencart site, I installed OC into a "development" directory -- ie. http://www.hersite.com/development

As I've been reviewing what she's gotten done so far, I notice that all the image links are absolute: www.hersite.com/development/image...

Is there anyway to change OC so the links are relative? So that when I copy her site to the root directory all the links won't have to be redone?

When I do move the files to the root directory, what files need to be edited. Tell it to me like I'm a newby.

Thanks.

Re: Relative vs absolute paths

Posted: Wed Jan 27, 2016 8:58 am
by Randem
Hi geotnt,

I don't quite understand...
Set the path in the config.php files (root and admin) the path is absolute. If you point it to where the images are then that is where they will be gotten from. Reminder the correct path for the images is image/catalog so in the config.php files for the images

define('DIR_IMAGE', '/home/content/57/10005557/html/opencarttest/image/');

OpenCart adds catalog to the defined path.

Re: Relative vs absolute paths

Posted: Thu Jan 28, 2016 7:32 am
by geotnt
Randem, thanks for replying. Let me try to explain better.

Currently, she has a zencart site running at www.hersite.com (not the actual domain name)

To test and subsequently build her opencart site, opencart was installed at www.hersite.com/development

As she has been building her site, I've gone back and if I "view source" for one of her product pages, I see <img src="http://hersite/development/image/cache/ ... gename.jpg"

Once I move all her files from the "development" subdirectory, to the root directory, none of these image links will work, as the photos will actually be at <img src="http://hersite/image/cache/catalog/Iren ... gename.jpg"

One should be able to set opencart so that when building out a store, relative links are used. In this case <img src="/image/cache/catalog/Irene/images/imagename.jpg"

For the second part, is there a step by step that tells how to move from a subdirectory to a root directory and then what exactly needs to be edited in the .php files? Guess I don't really understand what the php files actually do - I haven't even looked at them to this point.

Thanks in advance

Re: Relative vs absolute paths

Posted: Thu Jan 28, 2016 7:49 am
by Randem
The only php file you need to edit is the config.php files to point to the new location. OpenCart has a fixed internal structure for the images in the catalog and cache/catalog folders. This is hard coded but is used with the
define('DIR_IMAGE', '/home/content/xx/1000xxxx/html/opencarttest/image/'); parameter

It will become DIR_IMAGE . catalog and DIR_IMAGE . cache/catalog so if you change the DIR_IMAGE to the root of define('DIR_IMAGE', '/home/content/xx/1000xxxx/html/image/'); it will do as you want, but the hard code structur will remain the same.

The html pages are generated on the fly so relative paths are not needed...

Re: Relative vs absolute paths

Posted: Fri Jan 29, 2016 7:20 am
by geotnt
Alright then. Thanks.

So, to move the store from the subdirectory to the root folder, is it as simple as dragging and dropping all the files from one to the other, since it's still on the same domain?

Re: Relative vs absolute paths

Posted: Fri Jan 29, 2016 7:31 am
by Randem
And changing the config.php files to point to the new location...

Re: Relative vs absolute paths

Posted: Fri Jan 29, 2016 10:40 am
by IP_CAM
just don't forget, to modify the .htaccess file accordingly as well, or it won't work!
Sample: Destination site-url/shop/index.php...

Code: Select all

# SEO URL Settings
RewriteEngine On
RewriteBase /shop/
And make sure, by checking into a Backup Copy of your DB, that you had no MOD installed,
adding some DIRECT LINKS to the DB (Shop-SUB), where the old Shop has been before.

Code: Select all

INSERT INTO `oc_blog_description` 
................ src="http://images.openshop.li/shop/image/data/vqmod-570x333.jpg" width="499" /></p>\r\n<p>\r\n .....

Code: Select all

INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id.......... (24, 0, 'INV-2015-00', 0, 'Ernie''s OpenShop', 'http://www.hitline.info/shop/', 2, 3, 'Hans', 'Meier', 'jti@jacob.ch', '
e.t.c. ;D
I would THEREFORE clean out a DB first, of such Data !

Good Luck ! ;)
Ernie
openshop.li

Re: Relative vs absolute paths

Posted: Sat Jan 30, 2016 12:19 pm
by gogoweb
geotnt wrote:Alright then. Thanks.

So, to move the store from the subdirectory to the root folder, is it as simple as dragging and dropping all the files from one to the other, since it's still on the same domain?
In opnecart links are relative by default. As others said you just need to properly adjust config.php / .htaccess after yuo copy / move the files.

Re: Relative vs absolute paths

Posted: Mon Feb 01, 2016 6:43 am
by geotnt
So, the config.php files have about a dozen or so lines. I just edit each of those lines to indicate the correct path and I'm done.

Except for the htaccess file. Where is it located? And, I'm still fuzzy on the details of what needs to be edited therein.

Re: Relative vs absolute paths

Posted: Mon Jun 13, 2016 1:13 am
by geotnt
Who has done this that can give me a step by step? Please?

Re: Relative vs absolute paths

Posted: Mon Jun 13, 2016 2:56 am
by Randem
1 - Move the store structure to where you want it to be
2 - Run repair_settings.php and select all the recommended paths
3 - Run your new store...

Re: Relative vs absolute paths

Posted: Sun Jun 19, 2016 11:50 pm
by geotnt
Can someone tell me if this will work?

My wife currently has a web domain, www.herdomain.com
Her host allows multiple addon domains, so she also has www.addondomain.com which is a subdomain located under public/html

We've developed her new site as a subdomain, currently at www.herdomain.com/development

Will it work if I change the directory name for subdomain to subdomain2 and then rename development to subdomain?

It seems like it should, but I'm unsure and help would be appreciated.

Re: Relative vs absolute paths

Posted: Mon Jun 20, 2016 9:26 am
by Burt65
geotnt wrote:Can someone tell me if this will work?

My wife currently has a web domain, http://www.herdomain.com
Her host allows multiple addon domains, so she also has http://www.addondomain.com which is a subdomain located under public/html

We've developed her new site as a subdomain, currently at http://www.herdomain.com/development

Will it work if I change the directory name for subdomain to subdomain2 and then rename development to subdomain?

It seems like it should, but I'm unsure and help would be appreciated.

You have a beautiful wife..
herdomain.JPG

herdomain.JPG (48.71 KiB) Viewed 4173 times


Now regarding your question, I think you should follow the instructions given to you in all the above posts, and if you want to try to just rename the directory instead, be my guest. If it works, great...

Re: Relative vs absolute paths

Posted: Mon Jun 20, 2016 8:19 pm
by D_comp
geotnt wrote:Randem, thanks for replying. Let me try to explain better.

Currently, she has a zencart site running at http://www.hersite.com (not the actual domain name)

To test and subsequently build her opencart site, opencart was installed at http://www.hersite.com/development

As she has been building her site, I've gone back and if I "view source" for one of her product pages, I see <img src="http://hersite/development/image/cache/ ... gename.jpg"

Once I move all her files from the "development" subdirectory, to the root directory, none of these image links will work, as the photos will actually be at <img src="http://hersite/image/cache/catalog/Iren ... gename.jpg"

One should be able to set opencart so that when building out a store, relative links are used. In this case <img src="/image/cache/catalog/Irene/images/imagename.jpg"

For the second part, is there a step by step that tells how to move from a subdirectory to a root directory and then what exactly needs to be edited in the .php files? Guess I don't really understand what the php files actually do - I haven't even looked at them to this point.

Thanks in advance
first, you wanted to try Opencart installed in a sub_dir (called "development")
then, now You want to move all source to webroot ?
as my point, you shoulde edit the config files, example like this:
// HTTP
define('HTTP_SERVER', 'http://domain/development/');

// HTTPS
define('HTTPS_SERVER', 'http://domain/development/');

// DIR
define('DIR_APPLICATION', '/home/user/public_html/development/catalog/');
define('DIR_SYSTEM', '/home/user/public_html/development/system/');
define('DIR_IMAGE', '/home/user/public_html/development/image/');
define('DIR_LANGUAGE', '/home/user/public_html/development/catalog/language/');
define('DIR_TEMPLATE', '/home/user/public_html/development/catalog/view/theme/');
define('DIR_CONFIG', '/home/user/public_html/development/system/config/');
define('DIR_CACHE', '/home/user/public_html/development/system/storage/cache/');
define('DIR_DOWNLOAD', '/home/user/public_html/development/system/storage/download/');
define('DIR_LOGS', '/home/user/public_html/development/system/storage/logs/');
define('DIR_MODIFICATION', '/home/user/public_html/development/system/storage/modification/');
define('DIR_UPLOAD', '/home/user/public_html/development/system/storage/upload/');
remove the sub_fir in each line

Re: Relative vs absolute paths

Posted: Tue Jun 21, 2016 11:40 am
by Randem
Hi D_comp,

I did give you the simplest way to achieve what you want to do. Try it before complicating the issue...
Put the file in the root of the new folder where you copied the OpenCart software to then run the repair_settings.php script, take all the defaults and recommendations and you should be all done.

Re: Relative vs absolute paths

Posted: Wed Jun 22, 2016 8:28 am
by geotnt
Can anyone else speak to the repair_settings.php script? Has anyone else used it? Is it possible malware?

Re: Relative vs absolute paths

Posted: Wed Jun 22, 2016 9:37 am
by Randem
You win... I give up ???

Re: Relative vs absolute paths

Posted: Thu Jun 23, 2016 5:50 am
by geotnt
Randem wrote:You win... I give up ???
Why? I don't know you and I'm leery of running scripts on my machines so I was asking if anyone could vouch for it.

I asked a simple question about renaming the directories and you want me to run a javascript on your say-so? That's not good computer security by any stretch.

Re: Relative vs absolute paths

Posted: Thu Jun 23, 2016 6:04 am
by Randem
All you had to do was read the information in the link... ???

Re: Relative vs absolute paths

Posted: Thu Jun 23, 2016 6:14 am
by geotnt
Sorry for being overly cautious. Everything in the link sounds good and simple, but there is still no info on where the script comes from, who has tried it, if it's good or bad - nothing.

Again, I'll ask the question: Is there any reason why I can't just rename the directories, edit the config files and be done with it? Seems to me that would be much easier than this. But, if it won't work, that's a whole other story.

Thanks for being patient.