本文介绍了codeigniter通话功能的控制器没有的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有那么多帖子concering这个问题。我什么都试过,但没有成功。

我用XAMPP V3.2.2在我的Windows 10的机器。在我的htdocs我得到了一个名为mysite的项目。在那里,我有codeigniter 3.0.3。

的config.php

  $配置['BASE_URL'] ='的http://本地主机/ mysite的/';$配置['index_page'] ='';

routes.php文件

  $路线['default_controller'] ='CI_home';

控制器CI_home.php:

 类CI_home扩展是CI_Controller {    功能__construct(){
        父:: __构造();
    }    公共功能指数($ LANG =''){
        $这个 - >负载>帮手(URL);
        $这个 - >负载>帮手('语言');
        $这个 - >朗GT&;负载($ LANG,$ LANG);
        $这个 - >负载>查看('view_home');
    }
}

当我称之为的http://本地主机/ mysite的,页面显示正确。

问题是,当我尝试的http://本地主机/ mysite的/ EN 的http://本地主机/ mysite的/指数/恩我从XAMPP收到了404。

但是,如果我尝试 HTTP://localhost/mysite/index.php/CI_home/index/en 它工作正常。

我做错了吗?我怎样才能删除CI_home /指数?

HTTP://localhost/mysite/.htaccess:

的.htaccess

  RewriteEngine叙述在
的RewriteCond $ 1 ^(指数\\ .PHP |资源|机器人\\ .txt)的!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]

如果启用了mod_rewrite我已经选中。

请帮帮我!

在此先感谢,
yab86


解决方案

尝试以下

这htaccess的

 选项+的FollowSymLinks
选项​​-Indexes
的DirectoryIndex index.php文件
RewriteEngine叙述上
的RewriteCond $ 1 ^(指数\\ .PHP |图片|机器人\\ .txt)的!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]

请在你的主目录下肯定htaccess的。

然后设置您的基本网址

  $配置['BASE_URL'] ='的http://本地主机/ yourproject /';

然后取出的index.php

  $配置['index_page'] ='';

<?php

class Ci_home extends CI_Controller {

    public function __construct() {
         parent::__construct();
    }

     public function index($lang = '') {
       $this->load->helper('url');
       $this->load->helper('language');
       $this->lang->load($lang, $lang);
       $this->load->view('view_home');
     }
}

Then make sure file name is Ci_home.php

Then your default route should be

When using default controller make sure is the same name as the controller you choose.

URI Routing

$route['default_controller'] = 'ci_home';

$route['(:any)'] = 'ci_home/index/$1';

这篇关于codeigniter通话功能的控制器没有的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:06