1

I have implemented a website in codeigniter , recently I upload it to the production server that has SSL on it.

The problem is , if I enter using "http", everything works fine. If I enter using "https" , then all css and js is not found. And the error is :

Mixed Content: The page at 'https://www.xxxx.com/' was loaded over a secure connection, but contains a form which targets an insecure endpoint 'http://www.xxxx.com/secure/validate_credentials'. This endpoint should be made available over a secure connection.

Mixed Content: The page at 'https://www.xxxx.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://www.xxxx.com/assets/font-awesome/css/font-awesome.css'. This request has been blocked; the content must be served over HTTPS.

I have already edit the config.php in codeigniter

e.g. $config['base_url'] = "https://www.xxxx.com/"

but still happen, how to debug and fix it? Thanks for helping

user782104
  • 13,233
  • 55
  • 172
  • 312

2 Answers2

2

You have everything in you error message:

This request has been blocked; the content must be served over HTTPS.

It looks like you have static link in your html to 'http'. So instead of using protocol directly in your html like that:

http://www.xxxx.com/assets/font-awesome/css/font-awesome.css

Change it to something like this:

assets/font-awesome/css/font-awesome.css

Also remember that if you are trying to use JS or CSS from other domains that are not configured to serve content with https you will encounter this issue.

maque
  • 676
  • 1
  • 6
  • 11
  • thanks for answering , but in my html I include the css / js like this, site_url("assets/js/jquery.min.js"); then how to fix it? – user782104 Apr 20 '15 at 06:16
  • 1
    there is answer to similar question already: http://stackoverflow.com/questions/19062775/site-url-with-https-prefix – maque Apr 20 '15 at 06:22
  • that means can not modify site_url to return https ?, as I have use it in many files, it would be nice if I can override that function, thanks – user782104 Apr 20 '15 at 06:27
  • have you tried to set you base url to empty (if you can): $config['base_url'] = '' ? – maque Apr 20 '15 at 06:37
  • http://stackoverflow.com/questions/11792268/how-to-set-proper-codeigniter-base-url – Ross Apr 20 '15 at 07:14
1

Like maque said You have everything in you error message

But it is recommended to use base_url() instead of site_url for resources and like css, js and images.

you may upgrade to Codeigniter 3.0 it is still in develop in the time of writing this answer but it is very solid at this stage and it has better version of base_url() and site_url() as you can now add the protocol in the argument like that

site_url("assets/js/jquery.min.js", "https")
Community
  • 1
  • 1
Reda
  • 711
  • 6
  • 17