Jump to content

Recommended Posts

I have enabled SSL on my site and now all images are broken, when I view the console of the browser the urls are of the format:

https://mydomain.com/https://mydomain.com/image.jpg

The domain is duplicated.

My configure.php is as follows:

define('HTTP_SERVER', 'http://' . $_SERVER['SERVER_NAME']);
define('HTTPS_SERVER', 'http://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL', true); // secure webserver for checkout procedure?
define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');
define('DIR_WS_HTTP_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '/');
  
define('DIR_FS_CATALOG', dirname($_SERVER['SCRIPT_FILENAME']) . '/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

define('DIR_FS_ADMIN', $_SERVER['DOCUMENT_ROOT'] . '/******/');

/* db congig here */

define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('FONT_PATH', DIR_FS_ADMIN);
define('DIR_WS_ICONS', 'images/icons/');

Similarly for the admin config

define('HTTP_SERVER', 'http://' . $_SERVER['SERVER_NAME']);
define('HTTPS_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL', true);
define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');
define('HTTP_CATALOG_SERVER', 'http://' . $_SERVER['SERVER_NAME']);
define('HTTPS_CATALOG_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL_CATALOG', 'false');
define('DIR_FS_DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);
  
define('DIR_WS_ADMIN', '/****/');
define('DIR_FS_ADMIN', $_SERVER['DOCUMENT_ROOT'] . '/****/');
define('DIR_WS_HTTPS_ADMIN', '/1eiow3j4rj4ioj3iodjewghjfq1/');
define('DIR_WS_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '/');
define('DIR_FS_CATALOG', $_SERVER['DOCUMENT_ROOT'] . '/');
define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');
define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages/');
define('DIR_FS_CATALOG_LANGUAGES', $_SERVER['DOCUMENT_ROOT'] . '/includes/languages/');
define('DIR_FS_CATALOG_IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/');
define('DIR_FS_CATALOG_MODULES', $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/');
define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

I had a similar problem for a js includes which had the issue until I put a trailing slash in front, so I guess the clue is in this?

Any ideas?

Share this post


Link to post
Share on other sites

@spacebiscuit75

35 minutes ago, spacebiscuit75 said:

My configure.php is as follows:


define('HTTP_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('HTTPS_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL', true); // secure webserver for checkout procedure?
define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');
define('DIR_WS_HTTP_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '/');
  
define('DIR_FS_CATALOG', dirname($_SERVER['SCRIPT_FILENAME']) . '/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

define('DIR_FS_ADMIN', $_SERVER['DOCUMENT_ROOT'] . '/******/');

/* db congig here */

define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('FONT_PATH', DIR_FS_ADMIN);
define('DIR_WS_ICONS', 'images/icons/');

Similarly for the admin config


define('HTTP_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('HTTPS_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL', true);
define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');
define('HTTP_CATALOG_SERVER', 'http://' . $_SERVER['SERVER_NAME']);
define('HTTPS_CATALOG_SERVER', 'https://' . $_SERVER['SERVER_NAME']);
define('ENABLE_SSL_CATALOG', 'false');
define('DIR_FS_DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);
  
define('DIR_WS_ADMIN', '/****/');
define('DIR_FS_ADMIN', $_SERVER['DOCUMENT_ROOT'] . '/****/');
define('DIR_WS_HTTPS_ADMIN', '/1eiow3j4rj4ioj3iodjewghjfq1/');
define('DIR_WS_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '/');
define('DIR_FS_CATALOG', $_SERVER['DOCUMENT_ROOT'] . '/');
define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');
define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages/');
define('DIR_FS_CATALOG_LANGUAGES', $_SERVER['DOCUMENT_ROOT'] . '/includes/languages/');
define('DIR_FS_CATALOG_IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/');
define('DIR_FS_CATALOG_MODULES', $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/');
define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');
define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

You need to change the http:// to https:// in the first two lines in both config files.

M


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

A quick update: upon further inspection I discovered that the images look as if they have the correct url:

<img src="images/foobar.jpg ...../>

However the console shows the url with the double domain as pointed out in my original post. 

If I inspect the DOM and add the leading slash the image appear. When I debug the code I can see that the url of the image is set by concatenating the params which the tep_image function requires:

tep_image('images/', .....

Therefore out of the box the url of the image is correct. If I switch to the http version the url is the same and it works.

This is very weird!

Share this post


Link to post
Share on other sites
10 minutes ago, ArtcoInc said:

@spacebiscuit75

You need to change the http:// to https:// in the first two lines in both config files.

M

Are you sure about that? Why would the http url be https? That seems like a hack to make it work, it doesn't make any difference here.

The example configure.php:

define('HTTP_SERVER', ''); // eg, http://localhost - should not be empty for productive servers
define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers

 

Edited by spacebiscuit75

Share this post


Link to post
Share on other sites

As I understand it, if there are http:// links in your shop, you want them to actually to be processed as https://, hence the need to have both in your config file(s).

Do a search in the forum. There are many threads here stating this exact same 'fix'.

M

(also, line 8 in the admin config file)

Edited by ArtcoInc

Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites
17 minutes ago, ArtcoInc said:

As I understand it, if there are http:// links in your shop, you want them to actually to be processed as https://, hence the need to have both in your config file(s).

Do a search in the forum. There are many threads here stating this exact same 'fix'.

M

(also, line 8 in the admin config file)

I'm an idiot - I was missing the : after https:

define('HTTPS_SERVER', 'https//' . $_SERVER['SERVER_NAME']);

The 'solution' to set the https version of the site as http is a hack in my opinion, regardless if many here on the forum have used this to fix the issue. If you're using this approach then I would fix the real cause of the issue instead of that work-around - just my two cents worth though!

 

Share this post


Link to post
Share on other sites
6 hours ago, spacebiscuit75 said:

The 'solution' to set the https version of the site as http is a hack in my opinion, regardless if many here on the forum have used this to fix the issue. If you're using this approach then I would fix the real cause of the issue instead of that work-around - just my two cents worth though!

Having the http and https server versions in the config dates back to a time when sites would only use ssl for some pages - account and checkout and not the whole thing. Nowadays you probably want ssl across the whole site so set them both to https


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×