我已经在codeigniter编码我的网站和fb应用程序,目前正在 生产环境 和按预期工作,但我无法弄清楚 . 当我使用base_url时,它始终返回带有https协议的url,无论我目前正在使用http .
我在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值,该值由config读取)
在控制器中
$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 回答
这必须是主机问题而不是CodeIgniter . 检查你的htaccess文件是否正常,然后检查托管配置 .