0

I've the following rules on .htaccess file

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

But I'm getting this error enter image description here

What to do?

4
  • Provide the class definition of Default model. Also provide next line of exception message. Have you added model name to autoload array? Ex: $autoload['model'] = array('default_model'); Commented Nov 28, 2018 at 17:12
  • Finding the model has nothing to do with `.htaccess'. Show where you try to load the model. Commented Nov 28, 2018 at 22:22
  • This is not an htaccess problem. Put the model in the autoload and see if that helps. Check all your spelling Commented Nov 29, 2018 at 2:54
  • Put the code where you are loading model in School.php. Commented Nov 29, 2018 at 3:54

4 Answers 4

1

try this one hope so it will helpful for you.

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] 
Sign up to request clarification or add additional context in comments.

3 Comments

Can you add an explanation to your answer? Why exactly is the file given by the OP wrong, what have you changed to make it work?
in my .htaccess file the index.php file is run directly run, and all the other files like index\.php|images|css|js|robots\.txt|favicon\.ico run directly so there no chance to make a mistake. it works like this.
Please add all explanation to the answer, not to the comment section. Additionally, explain how such a change that works for you affects the OPs problem. As I would assume by the error message given in the screenshot, there is no connection to other request URIs
0

I've solved it. My model name was in lower case I've made it UC first. Thanks. default_model.php to Default_model.php

Comments

0

try to use this 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] 

1 Comment

Can you add an explanation to your answer? Why exactly is the file given by the OP wrong, what have you changed to make it work?
0

When creating models, you need to place the file in application/models/ and name the file in all lowercase - like default_model.php

Also one thing is important :

Your model file name must be ucfirst.

The default_model.php should contain the following:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Default_model extends CI_Model { public function __construct() { parent::__construct(); } ... 

3 Comments

yes show i also told you that you have to use ucfirst not lower case.
i just bold it see my answer.
and if it is right answer as you mentioned please give upvote. Thank you in advance

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.