CodeIgniter - Controller not found

1.7k Views Asked by At

I know this has been asked many times, and trust me that I've opened them all and following the steps but it still stuck for me. The css is also mess up (http://anakpanti.com/ab-cargo/)

I have CI project and it works in my localhost, but after I move it to webhosting the controller can't be found (except the default one).

The requested URL /ab-cargo/controllers_aboutus/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Here what have I done:

  • Change first letter controller class to capital
  • Change first letter filename controller to capital

Change.htaccess code into this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
  • Change file config into:

    $config['base_url'] = 'http://anakpanti.com/ab-cargo/';

    $config['index_page'] = '';

That's all the steps.

2

There are 2 best solutions below

0
On BEST ANSWER

Oh, I know the problem.

There should be 2 .htaccess files placed in the project.

First, in the root folder:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

And also inside the application folder:

<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
0
On

this is your baseurl right (http://anakpanti.com/ab-cargo/). S add rewiteBase /ab-cargo. Use this .htaccess

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

When including style sheet in header use base_url() in href tag

<link rel="stylesheet" href="<?php echo base_url();?>CSS/main.css" type="text/css">