CodeIgniter Forums
404s on Controller Methods - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: 404s on Controller Methods (/showthread.php?tid=77936)



404s on Controller Methods - bgoldstein24 - 11-06-2020

Working on migrating an app from v2 -> v3. 

In config.php: 
PHP Code:
$config['base_url'] = 'http://localhost/ci3';
$config['index_page'] = '';
$config['uri_protocol']    = 'REQUEST_URI'

My Login controller (controllers/Login.php):
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
    class 
Login extends CI_Controller{
        public function 
index(){
            
$data['main_content'] = 'login_form';
            
$data['page_title'] = 'Login';
            
$this->load->view('includes/login_signup_template'$data);
        }

        public function 
forgot(){
            
//load a view that collects the user's email address
            
$data['main_content'] = 'registration/forgot_collect_email';
            
$data['page_title'] = 'Forgot Password';
            
$this->load->view('includes/login_signup_template'$data);
        }

    } 

In routes.php: 
PHP Code:
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE

SO: 
https://localhost/ci3 -> This loads my login page. 
https://localhost/ci3/login/forgot -> This gets a 404 

Any ideas on what I am doing wrong here? This is driving me nuts.


RE: 404s on Controller Methods - midhunlalkc - 11-06-2020

Hi,
you need to set the route for forgot Page.

in routes.php

Code:
$route['login/forgot'] = 'login/forgot';



RE: 404s on Controller Methods - InsiteFX - 11-07-2020

Also your base_url should have an ending / slash on it.


RE: 404s on Controller Methods - bgoldstein24 - 11-07-2020

(11-07-2020, 09:10 AM)InsiteFX Wrote: Also your base_url should have an ending / slash on it.

Thanks for responding! I will add the / to it thanks for that. What I found was that if I put "index.php" back into all the URLs everything works fine. I follow the steps in the doc to remove "index.php" from the config, but I think I am missing something. I also made sure I updated .htaccess to process the rewrite. 

Are there any links that you know are reliable in their directions for removing "index.php"?