Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Igniter, Not Found 404 Error

I have a problem with my site. After upgrading to mySQL 5.6, then the host povider did a recompilation of Apache and PHP. apparently they also upgraded the WHM cPanel.

as for now my site can display properly, but when tried to login, it can't find the specific page requested.

The error Message:

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

error messages from cPanel:

[Mon Dec 22 10:10:58 2014] [error] File does not exist: /home/xxx/public_html/main [Mon Dec 22 10:10:56 2014] [error] File does not exist: /home/xxx/public_html/404.shtml

My analyses so far:

CI version : 2.2
PHP Version : 5.4.3.5
mySQL version : 5.6.21
cPanel Version 11.46.1 (build 4)

main -> is actually a file called main.php
cek_login -> is a function inside main.php that run verification against record in user table.

the folder structure as follows.

/home
   /application
       /controllers
           /main
       /view
          /login_view
   /system
   /assets
   /cgi-bin 

The code as follows

<div class="loginForm">
  <?=($_GET[ 'error'])? "<div class='alert'>$_GET[error]</div>": ""?>
    <form class="form-horizontal" action="<?php echo base_url().'main/cek_login'; ?>" method="POST">

config.php inside application folder
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI'; -> tried AUTO before, but useless. Previously was AUTO

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

.htaccess in another folder
deny from all

routes.php
$route['default_controller'] = "main";
$route['404_override'] = 'not_found';

I tried to see config files as well and tried a lot of tricks before posting this.

my suspicion is on the base_url function or the routing mechanism. I am not sure.

I am NEW to Code Igniter or PHP, also in Server Administration. my strength lies in Database.

Please help on narrowing the root problem.

best regards, Ridwan

like image 614
RidwanT Avatar asked Mar 18 '23 13:03

RidwanT


1 Answers

That error can happen for many reason. here is some
1.make sure you have main.php under controllers folder and inside main.php you should have a class Main which extends CI_Controller like this

class Main extends CI_Controller

2.make sure your .htaccess working.If your previous step is ok then try to hit this link

your_site_url/index.php/main/cek_login//make sure cek_login function exists inside the controller

If this link works you may have .htaccess problem
3.your cpanel error tells that your .htaccess not working.
check your server if it has main .htaccess which is redirecting your site if file not found.If so then your sub .htaccess will not work.
I think this is the main reason that produce your error.

like image 169
Shaiful Islam Avatar answered Mar 27 '23 16:03

Shaiful Islam