NOTE: This article will only work for Opencart versions prior to 1.5.5.1. It does not work for versions 1.5.5.1 or newer.

Google Page Speed recommends using a subdomain to store images that are loaded into your OpenCart store. When a web page tries to load images, scripts, and content they load one at a time. If you have a lot of images, it could dramatically impact your page load speeds. By having the images in a subdomain, they can load at the same time as the site does.

First, you’ll need to create a subdomain for the images in cPanel. During the set up of the subdomain  you’ll need to set the document root for the subdomain to the current folder where your images are stored. In this example, we set up the subdomain to images.inmotiontesting.com and pointed it to the existing image folder in the root folder of my OpenCart website.

Now, you have to edit the config.php file in the root of OpenCart as well as the config.php file in the admin folder:

Change:

define('HTTP_IMAGE', 'http://inmotiontesting.com/image/');

To:

define('HTTP_IMAGE', 'http://images.inmotiontesting.com/');

If you are using HTTPS, you’ll want to change the HTTP settings as well:

Change:

define('HTTPS_IMAGE', 'http://opencart.inmotiontesting.com/image/');

To:

define('HTTPS_IMAGE', 'http://images.inmotiontesting.com/');

If you want to test to make sure your changes have successfully worked, after you have made the changes above load your OpenCart site in a web browser. Then look at the source code to make sure all the image references are pointing to the subdomain. Here's what our new source code looks like:

<div id="logo">
   <a href="http://opencart.inmotiontesting.com/index.php?route=common/home">
     <img src="http://images.inmotiontesting.com/data/head_logo.gif" title="InMotion Hosting OpenCart Demo " alt="InMotion     Hosting OpenCart Demo " />
   </a>
</div>

If you need further assistance please feel free to ask a question on our support center.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-03-10 8:42 am

Good afternoon,

Here is present the case when is only one store (base store). But how must made in the the case of multi-stores when we have more stores added as sub-domains or addons domains?

I am very interested about subject, so I waiting your answer much early is possible.

Thank you for advice.

Best regards.

n/a Points
2014-05-07 10:37 am

This option is not available in 1.5.6. Please Advise how to set this in version 1.5.6

Staff
7,834 Points
2014-05-07 11:40 am
If the lines do not already exist, you may simply add them and OpenCart will use those directives.
n/a Points
2014-06-09 4:54 am

Don't you need to do this in the admin/config.php too, otherwise when you go to add an image in admin it will try to add it to the wrong folder?

Also, do you need to update the separate .htaccess file in the new subdomain to match your main ht.access file?

Staff
15,897 Points
2014-06-09 1:32 pm
Hello Aaron,

If the admin/config.php file has HTTP_IMAGE definitions, you will also want to change them there. I have added a sentence to the article stating that. As for the htaccess file, this should not need to be changed for this purpose.

Kindest Regards,
Scott M
n/a Points
2014-06-11 1:34 am

This is my config.php. What & How cane i change?

<?php// HTTPdefine('HTTP_SERVER', 'http://kitabonkiduniya.com/');// HTTPSdefine('HTTPS_SERVER', 'http://kitabonkiduniya.com/');// DIRdefine('DIR_APPLICATION', '/home/kitabonk/public_html/catalog/');define('DIR_SYSTEM', '/home/kitabonk/public_html/system/');define('DIR_DATABASE', '/home/kitabonk/public_html/system/database/');define('DIR_LANGUAGE', '/home/kitabonk/public_html/catalog/language/');define('DIR_TEMPLATE', '/home/kitabonk/public_html/catalog/view/theme/');define('DIR_CONFIG', '/home/kitabonk/public_html/system/config/');define('DIR_IMAGE', '/home/kitabonk/public_html/image/');define('DIR_CACHE', '/home/kitabonk/public_html/system/cache/');define('DIR_DOWNLOAD', '/home/kitabonk/public_html/download/');define('DIR_LOGS', '/home/kitabonk/public_html/system/logs/');// DBdefine('DB_DRIVER', 'mysql');define('DB_HOSTNAME', 'xxxxxxxxxx');define('DB_USERNAME', 'xxxxxxxxxxx');define('DB_PASSWORD', 'xxxxxxxxxxxxxx');define('DB_DATABASE', 'xxxxxxxxxx');define('DB_PREFIX', 'xxxxx');?>

Staff
7,834 Points
2014-06-11 7:59 am
You would simply change this line as described within the article:

define('DIR_IMAGE', '/home/kitabonk/public_html/image/');

n/a Points
2014-06-14 5:51 am

not working

Staff
15,897 Points
2014-06-15 8:20 am
Hello Absarul,

The article describes changing the HTTP_IMAGE definition. Your config.php does not contain that definition. Looking at a newly installed version of OpenCart, I do not see that definition either. I will check to see if the information here is either out of date or covering a specific type of setup.

Kindest Regards,
Scott M
n/a Points
2014-06-21 3:49 am
// HTTP
define('HTTP_SERVER', 'http://a2zfitnessmart.com/');
define('HTTP_IMAGE', 'http://img.a2zfitnessmart.com/');
// HTTPS
 define('HTTPS_SERVER', 'http://a2zfitnessmart.com/');
define('HTTPS_IMAGE', 'http://img.a2zfitnessmart.com/');

// DIR
define('DIR_APPLICATION', '\www.a2zfitnessmart.com/catalog/');
define('DIR_SYSTEM', '\www.a2zfitnessmart.com/system/');
define('DIR_DATABASE', '\www.a2zfitnessmart.com/system/database/');
define('DIR_LANGUAGE', '\www.a2zfitnessmart.com/catalog/language/');
define('DIR_TEMPLATE', '\www.a2zfitnessmart.com/catalog/view/theme/');
define('DIR_CONFIG', '\www.a2zfitnessmart.com/system/config/');
define('DIR_IMAGE', '\img.a2zfitnessmart.com/');
define('DIR_CACHE', '\www.a2zfitnessmart.com/system/cache/');
define('DIR_DOWNLOAD', '\www.a2zfitnessmart.com/download/');
define('DIR_LOGS', '\www.a2zfitnessmart.com/system/logs/'); 
Staff
15,897 Points
2014-06-23 6:44 am
Hello Anil,

What version of OpenCart are you using? Did the definition already exist for you to change or did you add it?

Kindest Regards,
Scott M
n/a Points
2014-06-24 2:12 am

Thanks for reply Mr. Scott.

I am using opencart 1.5.5.1. I am new for opencart and don't know how to change the definition. Please guide me about it.

Regards,

Anil Damiwal

Staff
7,834 Points
2014-06-24 8:31 am
Could you clarify what exactly the issue is? It appears that in the above comment, you only provided the configuration file and nothing more.
n/a Points
2014-06-25 2:45 am

I made subdomain (img.fitnessmart.com with folder name img), and copy image folder of root directory and paste into img folder. Both config files are changed like:

1. root/config.php:

// HTTPdefine('HTTP_SERVER', 'http://a2zfitnessmart.com/');
define('HTTP_IMAGE', 'http://img.a2zfitnessmart.com/');
// HTTPS
 define('HTTPS_SERVER', 'http://a2zfitnessmart.com/');
define('HTTPS_IMAGE', 'http://img.a2zfitnessmart.com/');

// DIR
define('DIR_APPLICATION', '\www.a2zfitnessmart.com/catalog/');
define('DIR_SYSTEM', '\www.a2zfitnessmart.com/system/');
define('DIR_DATABASE', '\www.a2zfitnessmart.com/system/database/');
define('DIR_LANGUAGE', '\www.a2zfitnessmart.com/catalog/language/');
define('DIR_TEMPLATE', '\www.a2zfitnessmart.com/catalog/view/theme/');
define('DIR_CONFIG', '\www.a2zfitnessmart.com/system/config/');
define('DIR_IMAGE', '\img/image/');
define('DIR_CACHE', '\www.a2zfitnessmart.com/system/cache/');
define('DIR_DOWNLOAD', '\www.a2zfitnessmart.com/download/');
define('DIR_LOGS', '\www.a2zfitnessmart.com/system/logs/'); 2. root/admin/config.php// HTTP
define('HTTP_SERVER', 'http://a2zfitnessmart.com/admin/');
define('HTTP_CATALOG', 'http://a2zfitnessmart.com/');
define('HTTP_IMAGE', 'http://img.a2zfitnessmart.com/');

// HTTPS
define('HTTPS_SERVER', 'http://a2zfitnessmart.com/admin/');
define('HTTPS_CATALOG', 'http://a2zfitnessmart.com/');
define('HTTPS_IMAGE', 'http://img.a2zfitnessmart.com/');

// DIR
define('DIR_APPLICATION', '\www.a2zfitnessmart.com/admin/');
define('DIR_SYSTEM', '\www.a2zfitnessmart.com/system/');
define('DIR_DATABASE', '\www.a2zfitnessmart.com/system/database/');
define('DIR_LANGUAGE', '\www.a2zfitnessmart.com/admin/language/');
define('DIR_TEMPLATE', '\www.a2zfitnessmart.com/admin/view/template/');
define('DIR_CONFIG', '\www.a2zfitnessmart.com/system/config/');
define('DIR_IMAGE', '\img/image/');
define('DIR_CACHE', '\www.a2zfitnessmart.com/system/cache/');
define('DIR_DOWNLOAD', '\www.a2zfitnessmart.com/download/');
define('DIR_LOGS', '\www.a2zfitnessmart.com/system/logs/');
define('DIR_CATALOG', '\www.a2zfitnessmart.com/catalog/');But images are not accessing in admin panel and website front page. So please guide me about that.
Staff
15,897 Points
2014-06-25 7:23 am
Hello Anil,

I installed and checked different versions of OpenCart and your versions (1.5.5.1) is the first version that does not support the HTTP_IMAGE definition. (1.4.4.1 is the last version to have this code) Adding the line to the config file does not break anything, but the definition is not used anywhere in the code. This article is unfortunately obsolete for OpenCart 1.5.5.1 and up. We will make the necessary changes to reflect that. Thank you for helping us to find this out.

Kindest Regards,
Scott M
n/a Points
2014-06-21 6:40 pm

not working for me either? Did you manage to find out a solution for this?

Staff
15,897 Points
2014-06-23 6:44 am
Hello Gabriel,

I will need a bit more information from you. What version of OpenCart are you using? Did the definition already exist for you to change or did you add it?

Kindest Regards,
Scott M
n/a Points
2014-06-24 9:37 pm

Warning: Image cache directory DIR_IMAGEcache/ not writeable!

Version 1.5.6.4

Images dont get cached and admin panel displays the above error....

I think you need to change these just before installation and not after

Staff
15,897 Points
2014-06-25 7:25 am
Hello Raka,

This article is about changing the HTTP_IMAGE definition and not the DIR_IMAGE definition. Unfortunately, OpenCart versions after 1.4.4.1 do not support the HTTP_IMAGE definition.

Kindest Regards,
Scott M
n/a Points
2014-07-14 12:25 pm
I am not sure, but I think you need more changes
Staff
15,897 Points
2014-07-14 2:41 pm
Hello MM,
After OpenCart 1.5.5.1, this does not work. It is only for versions prior to 1.5.5.1.

Kindest Regards,
Scott M

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

21 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!