Codeigniter 404在索引

时间:2016-10-14 05:04:32

标签: php codeigniter

所以我有一个客户在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控制器就像这样

<?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 Dev,我觉得这可能是该文件夹的权限问题。

如果有人可以提供帮助,会很高兴

1 个答案:

答案 0 :(得分:0)

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

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

在此之前,请确保您已在index_page

中将config.php设为空白

所以它应该是

$config['index_page'] = '';

现在这两个网址都可以使用http://domain.dev.com/index.php/what-is-chipilihttp://domain.dev.com/what-is-chipili