Q: How to use a subdomain for images
Posted: 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:
You would use:
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):
TO:
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):
TO:
If using SSL be sure you set this to use "https://" otherwise use "http://"
For 1.4.x:
1. EDIT: index.php
2. CHANGE:
TO:
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:
TO:
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
So instead of:
Code: Select all
http://www.mysite.com/shop/
http://www.mysite.com/shop/image/
Code: Select all
http://www.mysite.com/shop/
http://image.mysite.com/
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/');
Code: Select all
define('HTTP_IMAGE', 'http://image.mysite.com/');
3. CHANGE (for example):
Code: Select all
define('HTTPS_IMAGE', 'https://www.mysite.com/shop/image/');
Code: Select all
define('HTTPS_IMAGE', 'https://image.mysite.com/');
For 1.4.x:
1. EDIT: index.php
2. CHANGE:
Code: Select all
define('HTTP_IMAGE', HTTP_SERVER . 'image/');
Code: Select all
define('HTTP_IMAGE', 'http://image.mysite.com/');
3. CHANGE:
Code: Select all
define('HTTPS_IMAGE', HTTPS_SERVER . 'image/');
Code: Select all
define('HTTPS_IMAGE', 'https://image.mysite.com/');
In both versions, be sure you keep the trailing slash "/" at the end of the urls