1

I have a CI site with several form using jquery .click function, when I was in http its worked well, when I change to https all the form click button cannot be fire, its happen in localhost and in web host as well, is that anything need to config to run CI in https?

please advise and thanks!

Solved:

I just remove the url from $config['base_url'], and now the issue is solved, but I wonder how come when running https couldn't set value on $config['base_url']? hope someone would clear my doubt.

Thanks guy for taking time to view my question.

conmen
  • 2,377
  • 18
  • 68
  • 98
  • see also http://stackoverflow.com/questions/1500527/how-to-use-ssl-with-codeigniter – Vassilis Barzokas Jan 31 '13 at 10:12
  • my CI site works on both http and https without problem. Maybe you should try to use protocol-less `//` instead of `http://` in your URLs. – howanghk Jan 31 '13 at 10:16
  • So the site works fine, but the javascript doesn't? If so, you may want to tag your question appropriately. What is the .click() function supposed to do? Is it an ajax request? – Jeemusu Jan 31 '13 at 16:31

2 Answers2

0

Set your base_url protocol independent:

$config['base_domain'] = 'yourdomain.com'; // a new config item if you need to get your domain name
if (isset($_SERVER['HTTP_HOST']))
{
  $protocol = ($_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://');
  $config['base_url'] = $protocol.$_SERVER['HTTP_HOST'];
  $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
}
else
{
  $config['base_url'] = '';
}

I am guessing your ajax request fails because you are trying to access no-secure content from a secure site.

naabster
  • 1,494
  • 12
  • 14
0

I had a similar issue. I simply changed the base URL from HTTP to HTTPS in the config file and it worked well for both protocols.

# Base URL in codeigniter with HTTP
$config['base_url'] = 'http://mysite.abc/';

# Base URL in codeigniter with HTTPS
$config['base_url'] = 'https://mysite.abc/';

Remember, when you change HTTP to HTTPS, the site should work well for both protocols but it doesn't work the other way around.

Abu Shoeb
  • 4,747
  • 2
  • 40
  • 45