Php Codeigniter 404在除索引之外的每个URL上出现问题

Php Codeigniter 404在除索引之外的每个URL上出现问题,php,codeigniter,Php,Codeigniter,因此,我有一个客户谁在CI网站 当我下载了网站并尝试托管它时。索引页正在加载,但除所有其他链接外,其他链接都出现了404错误 路线是这样的 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $route['default_controller'] = "chipili"; $route['404_override'] = ''; $route['how-it-works']

因此,我有一个客户谁在CI网站

当我下载了网站并尝试托管它时。索引页正在加载,但除所有其他链接外,其他链接都出现了
404错误

路线是这样的

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



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


$route['how-it-works']      = "chipili/Commentcamarche/";
<?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');
}

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


如果有人能帮忙,我会很高兴的。好的,这就是您的htaccess问题。在根目录中创建
.htaccess
文件,如下所示

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在此之前,请确保在
config.php

应该如此

$config['index_page'] = '';

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

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

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在此之前,请确保在
config.php

应该如此

$config['index_page'] = '';


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

首先检查您的URL是否在控制器名称之前使用
index.php
,例如
demo.com/index.php/它是如何工作的
@rejoannalam我将添加哪个页面,对不起,我真的是新的如何你的网址尝试,并给你404error@RejoanulAlam所以这是有效的
http://domain.dev.com
但这不起作用
http://domain.dev.com/what-is-chipili
,是否还需要对.htacess文件进行任何更改,由于该网站位于live server上,现在我已在我的localNow上安装,请检查它是否正常工作
http://domain.dev.com/index.php/what-is-chipili
如果有效,则htaccess首先检查您的URL是否与控制器名称前的
index.php
一起工作,如
demo.com/index.php/如何工作
@rejoannalam第页我要添加这个吗,对不起,我真的是新的如何你的网址尝试,并给你404error@RejoanulAlam所以这是有效的
http://domain.dev.com
但这不起作用
http://domain.dev.com/what-is-chipili
,是否还需要对.htacess文件进行任何更改,由于该网站位于live server上,现在我已在我的localNow上安装,请检查它是否正常工作
http://domain.dev.com/index.php/what-is-chipili
if works and htaccess issueI检查了这两个选项,并添加了您提供的代码。htaccess是根目录的,但仍然不起作用。我重新启动了Apache服务,并且通过更改
$config['uri_protocol']
(在config.php中)正如
QUERY\u STRING
如果仍然没有工作,那么测试
REQUEST\u URI
,如果再次遇到相同的问题,那么
PATH\u INFO
,所以我应该将该配置的值更改为
QUERY\u STRING
对吗?是的,请尝试另外两个可用选项,即
REQUEST\u URI
PATH\u INFO
让我们一起检查。我同时检查了这两个选项并添加了您在根目录的.htaccess中提供的代码,但它仍然不起作用。我通过更改
$config['uri_protocol']]
(在config.php中)重新启动了Apache服务alsoNow测试正如
QUERY\u STRING
如果仍然没有工作,那么测试
REQUEST\u URI
,如果再次遇到相同的问题,那么
PATH\u INFO
,所以我应该将该配置的值更改为
QUERY\u STRING
对吗?是的,请尝试另外两个可用选项,即
REQUEST\u URI
PATH\u INFO
让我们来看看。