我遇到了與CodeIgniter: 404 Page Not Found on Live Server相同的問題。在應用/控制器,我的welcome.php像這樣:404當訪問Codeigniter頁面
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
然而,當我去mysite.com,mysite.com/welcome,mysite.com/Welcome和mysite.com/Welcome.php,我每次得到404。
我routes.php文件:
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
我有一個文件,Home.php:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('general_model');
}
public function index() {
$this->load->view("home/home_view");
}
/*
public function coming(){
$this->load->view("home/coming_soon_view");
}
*/
}
我的.htaccess:
RewriteEngine on
RewriteCond $1 !^(phpMyAdmin|index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
我真的很掙扎,看我做錯了什麼。
你是什麼'config ['index']'var設置爲? – Kisaragi
從config.php內? –
是的,'$ config ['index_page']' – Kisaragi