php - One Codeigniter website and application together

I have a Codeigniter website and i want users and admins to be able to access the respective systems through the main website example showed below, I have the main controller set in routes.php and I have generated folders for admin and user under the controller folder and Views folder. The main website works well but when I click the links to go to login for admin or user I get a 404 error, am not sure if i have implemented the structure correctly or its the logic which is wrong. This is an example of how am calling the user login from the main site
<?php echo base_url(); ?>user/user.php">
Routes.php
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Project tree structure
Fun4lend
в”њв”Ђ .editorconfig
в”њв”Ђ .gitignore
в”њв”Ђ application
в”‚ в”њв”Ђ .htaccess
в”‚ в”њв”Ђ config
в”‚ в”‚ в”њв”Ђ autoload.php
в”‚ в”‚ в”њв”Ђ config.php
в”‚ в”‚ в”њв”Ђ constants.php
в”‚ в”‚ в”њв”Ђ database.php
в”‚ в”‚ в”њв”Ђ doctypes.php
в”‚ в”‚ в”њв”Ђ foreign_chars.php
в”‚ в”‚ в”њв”Ђ hooks.php
в”‚ в”‚ в”њв”Ђ index.html
в”‚ в”‚ в”њв”Ђ memcached.php
в”‚ в”‚ в”њв”Ђ migration.php
в”‚ в”‚ в”њв”Ђ mimes.php
в”‚ в”‚ в”њв”Ђ profiler.php
в”‚ в”‚ в”њв”Ђ routes.php
в”‚ в”‚ в”њв”Ђ smileys.php
в”‚ в”‚ в””в”Ђ user_agents.php
в”‚ в”њв”Ђ controllers
в”‚ в”‚ в”њв”Ђ admin
в”‚ в”‚ в”‚ в””в”Ђ Welcome.php
в”‚ в”‚ в”њв”Ђ Auth.php
в”‚ в”‚ в”њв”Ђ home.php
в”‚ в”‚ в”њв”Ђ index.html
в”‚ в”‚ в””в”Ђ user
в”‚ в”‚ в””в”Ђ Auth.php
в”‚ в”њв”Ђ core
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ helpers
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ hooks
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ index.html
в”‚ в”њв”Ђ language
в”‚ в”‚ в”њв”Ђ english
в”‚ в”‚ в”‚ в””в”Ђ index.html
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ libraries
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ models
в”‚ в”‚ в”њв”Ђ index.html
в”‚ в”‚ в””в”Ђ register_model.php
в”‚ в”њв”Ђ third_party
в”‚ в”‚ в””в”Ђ index.html
в”‚ в””в”Ђ views
в”‚ в”њв”Ђ about.php
в”‚ в”њв”Ђ about_us.php
в”‚ в”њв”Ђ admin
в”‚ в”њв”Ђ errors
в”‚ в”‚ в”њв”Ђ cli
в”‚ в”‚ в”‚ в”њв”Ђ error_404.php
в”‚ в”‚ в”‚ в”њв”Ђ error_db.php
в”‚ в”‚ в”‚ в”њв”Ђ error_exception.php
в”‚ в”‚ в”‚ в”њв”Ђ error_general.php
в”‚ в”‚ в”‚ в”њв”Ђ error_php.php
в”‚ в”‚ в”‚ в””в”Ђ index.html
в”‚ в”‚ в”њв”Ђ html
в”‚ в”‚ в”‚ в”њв”Ђ error_404.php
в”‚ в”‚ в”‚ в”њв”Ђ error_db.php
в”‚ в”‚ в”‚ в”њв”Ђ error_exception.php
в”‚ в”‚ в”‚ в”њв”Ђ error_general.php
в”‚ в”‚ в”‚ в”њв”Ђ error_php.php
в”‚ в”‚ в”‚ в””в”Ђ index.html
в”‚ в”‚ в””в”Ђ index.html
в”‚ в”њв”Ђ homepage.php
в”‚ в”њв”Ђ home_loan.php
в”‚ в”њв”Ђ index.html
в”‚ в”њв”Ђ loan_business.php
в”‚ в”њв”Ђ loan_property.php
в”‚ в”њв”Ђ loan_register.php
в”‚ в”њв”Ђ loan_system.php
в”‚ в”њв”Ђ personal_loan.php
в”‚ в”њв”Ђ site.php
в”‚ в”њв”Ђ user
в”‚ в”‚ в”њв”Ђ loan_register.php
в”‚ в”‚ в””в”Ђ user.php
в”‚ в””в”Ђ welcome_message.php
Answer
Solution:
following your directory tree:
you don't have a controller namedUser.php
in your folder controllers/user. There is only one controller calledAuth.php
, therefore
<?php echo base_url(); ?>user/user.php">
doesn't work, and returns a 404, file not found error
btw, the correct Codeigniter way to call that User.php controller would look like this:
<?php echo base_url('user/user');?>
either you add that controller, or you change the link to point to auth.php
read Organizing Your Controllers into Sub-directories and URL Helper base_url()
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: closed without sending a request; it was probably just an unused speculative preconnection
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.