Post by rwassell » Mon Feb 06, 2017 6:39 pm

I am unable to get multi-store working on two different domains with two SSL certificates and I really hope someone can shed some light on this, for example:

The problem is, with SSL enabled and both stores operating on HTTPS, that the second store will show the first stores content. When the second stores main store URL is set to HTTP it is fine, when it is set to HTTPS is when the problem occurs.

OC version 1.5.2.1
VQMod installed, enabled but no VQMod files in place to remove potential confusion or conflict
Store path: /home/sites/opencart/
First : http://firststoredomain.co.uk
Second: http://secondstoredomain.co.uk

Using HTTP (non-SSL) both stores work perfectly.

SSL certificates setup using Let's Encrypt. We want both stores to operate fully on HTTPS and we are forwarding non-HTTP to HTTPS.

1) Update ../opencart/config.php to specify all instances of HTTP as HTPS
2) Update ../opencart/admin/config.php to specify all instances of HTTP as HTTPS
3) Edit system store configuration for default store 1 to be https://firststoredomain.co.uk/ - SSL Enabled
4) Edit store configuration for store 2 to be https://secondstoredomain.co.uk/ for both HTTP and HTTPS - SSL Enabled

Problem: Store 2 shows Store 1 content

5) If you edit store 2 and set the main store URL to be http://secondstoredomain.co.uk, whilst it won't look right as it can't load .css it is at least loading the correct store content.

So the problem all points at the main store URL being https instead of http.

I have checked everything, it has nothing to do with wildcard SSL certificates, nothing to do with server paths, nothing to do with .htaccess or web server configuration. I believe it is definitely something to do with Opencart and perhaps the multi-store programming not able to determine the route to content when the second store is using HTTPS just like the first store, hence showing store 1 content and not store 2.

I've spent 2.5 days researching and investigating this problem and have not been able to find a solution on this forum or any other resource. Someone must have encountered this previously and with Google insisting on all stores having an SSL certificate I imagine more will encounter it.

Thank you for your help.

Rob

(Note: I have asked Qphoria to help me with this so dependent on who find the solution first, I will ensure that this post is updated so that we have a final solution on record.)

New member

Posts

Joined
Thu Apr 12, 2012 3:38 am

Post by EvolveWebHosting » Tue Feb 07, 2017 5:47 am

A few suggestions:

1) Add this to your .htaccess file:

Right below RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

2) Try a # before Options +FollowSymlinks

#Options +FollowSymlinks

3) Let's Encrypt is a neat tool but it's not a great certificate option and could be your issue. You may need to purchase 2 self signed certificates instead.

Opencart Hosting Plans, Domain Registration, Microsoft and Google Email and More
Visit our website for great deals and most importantly, fast and friendly support - www.evolvewebhost.com


User avatar
Active Member

Posts

Joined
Fri Mar 27, 2015 11:13 pm
Location - Denver, Colorado, USA

Post by rwassell » Tue Feb 07, 2017 4:43 pm

The great Qphoria resolved the problem.

Due to a proxy server being involved (in our case, Varnish) some code was required to 'validate the proxy variable instead of using the normal HTTPS check'.

In the root folder: index.php

Original code:

Code: Select all

// Store
if (isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
	$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
	$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
}
New code:

// Store
if ((isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) || (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && $_SERVER['HTTP_X_FORWARDED_PORT'] = 443)) {
$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
}

Thank you Qphoria.

I hope this helps someone as it has helped us.

Rob

New member

Posts

Joined
Thu Apr 12, 2012 3:38 am

Post by hamidg84 » Sat May 13, 2017 5:49 am

Hello

This solved 50% of similar issue we were facing but have another problem now

Domain A has https on all pages, thats how we want
Domain B,C,D have https enabled on Home page only and checkout but we need to have https on all pages,

Any fix please?

Active Member

Posts

Joined
Wed Feb 29, 2012 6:18 am

Post by hamidg84 » Mon May 15, 2017 5:17 am

any help please?

Active Member

Posts

Joined
Wed Feb 29, 2012 6:18 am
Who is online

Users browsing this forum: No registered users and 83 guests