Post by Qphoria » Sat Sep 10, 2011 1:58 am

According to Google Page Speed and other resources on the net, it is recommended to use a subdomain for your image loading as opposed to a subdirectory.

So instead of:

Code: Select all

http://www.mysite.com/shop/
http://www.mysite.com/shop/image/
You would use:

Code: Select all

http://www.mysite.com/shop/
http://image.mysite.com/
You can do this easily in OpenCart.

1. Goto your webhost's cpanel and click the "Subdomains" area
2. Setup a new subdomain called "image.mysite.com". (replace "mysite" with your real site)
3. Setup the redirect for that subdomain to point to your current store url to the image path
(e.g. http://www.mysite.com/shop/image/)

Now you have setup the subdomain to point directly to your store image folder. Now you will want to set the new subdomain in opencart.

For 1.5.x:
1. EDIT: config.php

2. CHANGE (for example):

Code: Select all

define('HTTP_IMAGE', 'http://www.mysite.com/shop/image/');
TO:

Code: Select all

define('HTTP_IMAGE', 'http://image.mysite.com/');
Notice I removed the "shop/image" after the ".com" part. Since you've included the store path as part of the redirect path, you don't need to include it as part of this path.


3. CHANGE (for example):

Code: Select all

define('HTTPS_IMAGE', 'https://www.mysite.com/shop/image/');
TO:

Code: Select all

define('HTTPS_IMAGE', 'https://image.mysite.com/');
If using SSL be sure you set this to use "https://" otherwise use "http://"



For 1.4.x:
1. EDIT: index.php

2. CHANGE:

Code: Select all

define('HTTP_IMAGE', HTTP_SERVER . 'image/');
TO:

Code: Select all

define('HTTP_IMAGE', 'http://image.mysite.com/');
Notice I removed the "shop/image" after the ".com" part. Since you've included the store path as part of the redirect path, you don't need to include it as part of this path.


3. CHANGE:

Code: Select all

define('HTTPS_IMAGE', HTTPS_SERVER . 'image/');
TO:

Code: Select all

define('HTTPS_IMAGE', 'https://image.mysite.com/');
If using SSL be sure you set this to use "https://" otherwise use "http://"



In both versions, be sure you keep the trailing slash "/" at the end of the urls

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Mon Mar 02, 2015 8:00 am

In 1.5.6 and later, the HTTP_IMAGE was removed.
This vQmod should add that functionality back (lightly tested).
To use, be sure you have the HTTP_IMAGE and HTTPS_IMAGE constants set in your config.php and admin/config.php file
Then use the attached vQmod script

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 4 guests