Codeigniter 404问题在每个URL除了索引


Codeigniter 404 issue on every URL other than index

所以我有一个客户谁在CI网站。

当我下载网站并试图托管它时。索引页正在加载但是其他链接都显示了404 ERROR

路由是这样的

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

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

$route['how-it-works']      = "chipili/Commentcamarche/";

chipili Controller是这样的

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Chipili extends CI_Controller {
    protected $data = array();
    function __construct ()
    {
        parent::__construct();
        $this->data['title'] = 'domain : un spectacle à la maison';
        $this->data['meta_title'] = 'domain : un spectacle à la maison';
        $this->data['meta_desc'] = 'domain : un spectacle à la maison';
        //$this->data['lang'] = 'fr';
        $this->data['content']  = 'index/index';
        //$this->redirectCountry();
    }
    public function redirectCountry() {
        include(APPPATH.'libraries/geoplugin.php');
        $geoplugin = new geoPlugin();
        $geoplugin->locate();
        $country_code = $geoplugin->countryCode;
        if($country_code == 'FR'){
                if($_SERVER['SERVER_NAME'] != 'www.domain.com'){
                    header('Location: http://www.domain.com');
                }
        }
        elseif ($country_code == 'AE'){
            if($_SERVER['SERVER_NAME'] != 'ae.domain.com'){
                    header('Location: http://ae.domain.com');
            }
        }
    }
    /**
     * Index Page for this controller.
     *
     * 
     */
    public function set_language () {       
        switch ($_SERVER['SERVER_NAME']){
            case 'www.domain.com':
                $this->session->set_userdata('lang', 'fr');
                break;
            case 'en.domain.com';
                $this->session->set_userdata('lang', 'en');
                break;
            case 'ae.domain.com';
                $this->session->set_userdata('lang', 'ae');
                break;
            default:
                $this->session->set_userdata('lang', 'fr');
                break;  
        }
    }
    public function index()
    {

        $this->set_language();
        $this->lang->load('index', $this->session->userdata('lang'));
        $this->data['title'] = $this->lang->line('title');
        $this->data['meta_title'] = $this->lang->line('meta_title');
        $this->data['meta_desc'] = $this->lang->line('meta_desc');
        $this->data['content']  = 'index/index';
        $this->load->vars($this->data);
        $this->load->view('template');
    }
 /**
 * Page Comment ca marche
 * url : concert-et-spectacle-a-domicile
 * 
 */
public function Commentcamarche () {
    $this->data['title'] = "How it work";
    $this->data['meta_title'] = "How it work";
    $this->data['meta_desc'] = "How it work";
    $this->data['content']  = 'chipili/commentcamarche';
    $this->load->vars($this->data);
    $this->load->view('template');
}
}

. htaccess

AddCharset UTF-8 .html
Options +FollowSymlinks
ExpiresActive On
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType text/css "access plus 1 months"
ExpiresByType text/javascript "access plus 1 months"
ExpiresByType application/javascript "access plus 1 months"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond $1 !^(index'.php|public|css|js|robots'.txt|citelis|cgi-bin|medias|uploads|favicon'.ico|sitemap'.xml)  
Options +FollowSymlinks
php_flag display_errors on

我是一名Laravel开发人员,根据我的经验,我觉得这可能是文件夹的权限问题。

如果有人能帮忙我很高兴

这就是你的htaccess问题。在根目录下创建.htaccess文件,如下所示

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

在此之前,请确保将index_page设置为config.php中的空白

所以应该是

$config['index_page'] = '';

,现在两个URL都可以工作http://domain.dev.com/index.php/what-is-chipilihttp://domain.dev.com/what-is-chipili