如何解决Codeigniter .htaccess错误?

时间:2018-11-28 17:06:01

标签: php codeigniter

我对.htaccess文件有以下规则

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

但是我遇到这个错误 enter image description here

该怎么办?

4 个答案:

答案 0 :(得分:1)

尝试这一希望,它将对您有所帮助。

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

答案 1 :(得分:0)

尝试使用此htaccess

Options All -Indexes
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

答案 2 :(得分:0)

创建模型时,需要将文件放置在application / models /中,并用小写形式命名文件-例如default_model.php

还有一件很重要的事情:

您的模型文件名必须为 ucfirst

default_model.php应该包含以下内容:

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


class Default_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }
    ...

答案 3 :(得分:0)

我已经解决了。我的型号名称是小写字母,我首先将它设为UC。谢谢。      default_model.php Default_model.php