Codeigniter,base_url总是在url中返回https协议

时间:2013-06-05 21:43:44

标签: codeigniter https base-url

我已经在codeigniter编码了我的网站和fb应用程序,目前正在制作中并按预期工作但我无法弄明白。当我使用base_url时,如果我当前正在使用http,它总是返回带有https协议的url。

我在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'] = '';

最初网站和应用只是https,但我发现谷歌广告不支持它,所以我必须让网站也在http工作。

实施例: (portalshared ['base_url']携带我的控制器的base_url值,该值由配置读取)

控制器中的

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

在视图中

<?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 } ?>

结果:

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

预期结果(因为我正在浏览http网站):

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

由于某些原因,我的codeigniter没有正确猜出协议?

1 个答案:

答案 0 :(得分:0)

这必须是主机问题,而不是CodeIgniter。检查你的htaccess文件是否正常,然后检查托管配置。