404找不到index.php正在工作

时间:2014-11-15 09:59:01

标签: codeigniter

我已经完成了一个项目,它与我的本地服务器工作正常但是当我把它放在一个实时服务器上时,它给了我404 Not Found - 404.html当我试图访问其他页面时。只有index.php工作其余的不是。我正在使用codeigniter 2.2.0。要检查我的代码是否存在问题,我上传了默认的codeigniter。我只有两页welcome.php和one.php。这是实时网址http://www.fhi365.com/

这是我的配置文件。

$config['base_url'] = 'http://www.fhi365.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

这是我的常数

define('BASEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/');

这是我的路线

$route['default_controller'] = "welcome";
$route['404_override'] = '';

这是我的控制器

public function index()
    {
        $this->load->view('welcome_message');
    }

    public function one(){
        $this->load->view('one_view');
    }

我没碰过.htacces。

有人可以帮助我。

感谢。

2 个答案:

答案 0 :(得分:0)

您应该信任codeigniter base_url()或site_url()。他们总是返回正确的网址。

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

你必须注意.htaccess。如果是启用

如果 ROOT

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

如果 SUBFOLDER

RewriteEngine on
RewriteBase /directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

答案 1 :(得分:0)

这就是问题的解决方法。

@Florin说信任codeigniter。

所以这是我的配置

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
@Shaiful Islam说我需要把“?”我的常数上的index.php。

这是我的常数

define('BASEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/index.php?/');

WEW!这对我来说很好。