【问题标题】:Codeigniter, base_url always returns https protocol in urlCodeigniter,base_url 总是在 url 中返回 https 协议
【发布时间】:2013-06-05 21:43:43
【问题描述】:

我已经在 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 没有正确猜测协议?

【问题讨论】:

    标签: codeigniter https base-url


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2016-04-22
      • 2016-04-17
      • 2015-08-05
      • 1970-01-01
      • 2019-01-09
      • 2013-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多