Page 1 of 1

Forced SSL breaks CSS on SEO url's

Posted: Tue Apr 19, 2016 8:13 pm
by R_D
Who can help me out:

I've installed a clean OC 2.2.0.0 on a subdomain and want to force SSL on all pages.
I've altered the

Code: Select all

$_['site_ssl']          = false;
in the System/Config/admin.php, catalog.php and default.php to

Code: Select all

$_['site_ssl']          = true;
because if you only enable SSL in the admin site config, nothing happens.

Also I've changed the System/Library->url.php

Code: Select all

$url = 'http://' . $_SERVER
to

Code: Select all

$url = 'https://' . $_SERVER
to force https

The urls in config.php and admin/config.php are adjusted to https.

The .htaccess file is renamed and I've inserted the following code

Code: Select all

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
All is well, the site is forced into SSL BUT it only works for (SEO) urls without 'children':

https://store.mydomain.com/category works (but not if you add a '/' to the end of the url)
but

https://store.mydomain.com/category/category-child or
https://store.mydomain.com/category/product

doesn't work; the CSS is broken.

CSS files like /catalog/view/theme/default/stylesheet/stylesheet.css and JS like /catalog/view/javascript/bootstrap/js/bootstrap.min.js are being added after the https://store.mydomain.com/category becoming https://store.mydomain.com/category/catalog/view/theme/default/stylesheet/stylesheet.css


How can I fix this?

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 12:59 am
by derv.god
Hi,
I had the exact same problem. I have posted the answer in my thread.

http://forum.opencart.com/viewtopic.php?f=190&t=160983

If you find a different solution to this please let me know. It has been a pain finding the problem->solution.


Regards

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 3:24 am
by R_D
Good lord, you've saved my day ;D

I encountered 1 problem with it: if you do what you said in the other post you can't search because you're missing a "/".
in catalog/controller/common/header.php on line 27
your code:

Code: Select all

$data['base'] = "//mydomain.com";
Code so search is working:

Code: Select all

$data['base'] = "//mydomain.com/";

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 7:43 am
by Randem
The solutions for this can be found here - Changes made to correct issues in OpenCart for v2.2.0.x

You will run into other issues in V2.2.0.0 with SSL - OpenCart 2.2.0.0 Testing - Issues to Expect...

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 2:02 pm
by R_D
Hi Randem,

I've already seen your post and seen the files attached but this problem couldn't be solved with that (as far as I know).

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 2:33 pm
by Randem
How did you come to determine that? Hopefully not just by looking at it...I post the fixes because they work and I use forced SSL.

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 2:40 pm
by R_D
Haha, no not by only looking at it, :laugh: :laugh: I've incorporated most fixes (thanks for that by the way)

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed Apr 20, 2016 2:47 pm
by Randem
You are welcome 8) Some humor is needed in life :laugh:

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed May 25, 2016 12:15 am
by R_D
Something strange happens when I want to view an order:

I receive an"Error undefined" message. When I use Chromes developers console I can see this:

XMLHttpRequest cannot load httpss://shop.myshop.com/index.php?route=api/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Take note of the "httpss" it's not a typo :choke:

Anyone some ideas to solve this?

Re: Forced SSL breaks CSS on SEO url's

Posted: Wed May 25, 2016 7:06 pm
by R_D
For anyone with the same problem:

https://github.com/opencart/opencart/pull/4353/files

This is the solution...

Re: Forced SSL breaks CSS on SEO url's

Posted: Sat May 28, 2016 11:34 pm
by OMDB
This works for me:

Code: Select all

      if ($this->request->server['HTTPS']) {
            $server = 'https://'.$this->config->get('site_base');
      } else {
            $server = $this->config->get('config_url');
      }
Thus, no need to hardcode the actual domain in the code.

Re: Forced SSL breaks CSS on SEO url's

Posted: Mon May 30, 2016 9:47 pm
by R_D
OMDB wrote:This works for me:

Code: Select all

      if ($this->request->server['HTTPS']) {
            $server = 'https://'.$this->config->get('site_base');
      } else {
            $server = $this->config->get('config_url');
      }
Thus, no need to hardcode the actual domain in the code.
in what file and what line do you alter this? Thanks!

(....already have it ;) )