CodeIgniter网站在迁移在线服务器后重定向到localhost


CodeIgniter website redirect to localhost after migrating online server

我刚刚在我的托管帐户上上传了我的应用程序,该帐户由hostinger提供。你可以在这里看到链接。

配置文件:

<?php
class SystemConfiguration {
// General Settings
public static $base_url    = 'http://primodebug.esy.es/Calendario/';
// Database Settings
public static $db_host     = 'mysql.hostinger.it';
public static $db_name     = 'u460105738_primo';
public static $db_username = 'u460105738_ferve';
public static $db_password = '*****';

CodeIgniter config.php文件(太长,无法粘贴到此处)。

.HTACESS

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] 

我在记录可能相关的文件时也遇到了其他问题。httaccess我不知道,但似乎有些javascript文件没有正确加载。可以是什么?

首先要查找的位置是/application/config/config.php,其中$config['base_url']项应设置为您的托管帐户。

 $config['base_url'] = 'http://primodebug.esy.es/';

如果设置为如图所示,那么在代码的其他地方就硬编码了"localhost"。

在本例中,Codeigniter的"URL Helper"需要在加载SystemConfiguration之前加载。因此,在加载SystemConfiguration之前,请在某处运行$this->load->helper('url');。或者,它可以像这样在SystemConfiguration的构造函数中完成。

<?php
class SystemConfiguration {
// General Settings
public static $base_url;
// Database Settings
public static $db_host     = 'mysql.hostinger.it';
public static $db_name     = 'u460105738_primo';
public static $db_username = 'u460105738_ferve';
public static $db_password = '*****';
}
function __construct()
{
  $this->CI->load->helper('url');
  $this->base_url = base_url('Calendario/')
}