0
votes

i have coded my website and fb app in codeigniter, currently in production and working as expected but i can't figure out something. When i use base_url it always returns the url with https protocol not matter if i'm currently using http.

i have this in my config.php

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = '';

Initially the website and app were https only but i found out that google ads do not support it so i have to make the site work in http as well.

Example: (the portalshared['base_url'] carries the base_url value from my controller which is being read by the config)

in controller

$this->portalshared = array('base_url' => $this->config->item('base_url') ...

in view

<?php foreach ($mostviewed as $post) { ?>
<tr>
<td>
<a target="_blank" href="<?php echo $this->portalshared['base_url'].'portal/post/'.(string)$post['_id'].'.html';?>"><?php echo $post['message'];?></a>
</td>
</tr>
<?php } ?>

Result:

<tr>
<td>
<a href="https://mydomain/portal/post/51a5ee91c993888b63000007.html" target="_blank">message here</a>
</td>
</tr>

Expected result (since i'm browsing the http site):

<tr>
<td>
<a href="http://mydomain/portal/post/51a5ee91c993888b63000007.html" target="_blank">message here</a>
</td>
</tr>

For some reason my codeigniter does not guess the protocol correctly?

1

1 Answers

0
votes

This must be host issue rather than CodeIgniter. Check your htaccess file if it is ok, then check hosting configs.