CodeIgniter Forums
404 error from codeigniter when hosted to server (tried every possible conditions) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: 404 error from codeigniter when hosted to server (tried every possible conditions) (/showthread.php?tid=73754)

Pages: 1 2 3 4


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 05-31-2019

(05-31-2019, 09:45 PM)Paradinight Wrote:
(05-31-2019, 05:39 AM)chinna Wrote:
(05-31-2019, 04:57 AM)dave friend Wrote: Are you trying to use any special routes?

Please show us the code for the controller and view of one such page.

index is working but login is showing 404 error

First fix the password code... .

https://paragonie.com/blog/2017/12/2018-guide-building-secure-php-software#secure-php-passwords

Second: https://www.codeigniter.com/user_guide/installation/upgrade_300.html?#step-13-check-for-usage-of-the-xss-clean-form-validation-rule

Third: Update the php version 5.5 is very old


Back to the problem:
Check if the .htaccess is allowed
may be first two are not the reasons because even when i try to display a static page then also im getting 404 error from codeigniter

third one i upgraded the php to 7.3 still im getting same 404 error


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - demyr - 06-01-2019

Can you please write your problem/details/folder structures etc. step by step. So that we can figure it out correctly instead of hitting our head against a brick wall.

For example You mentioned that : "i checked capital letter at starting." in your first post. Did you check the First letters of Model names and Controller names in your related directories?

Or your index function starts with an if(isset()).. What about the else part of the block?

By the way, before everything, can you please try any, simple, "hello world" text to test the welcome page?

Regards.


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 06-01-2019

(06-01-2019, 02:07 AM)demyr Wrote: Can you please write your problem/details/folder structures etc. step by step. So that we can figure it out correctly instead of hitting our head against a brick wall.

For example You mentioned that : "i checked capital letter at starting." in your first post. Did you check the First letters of Model names and Controller names in your related directories?

Or your index function starts with an if(isset()).. What about the else part of the block?

By the way, before everything, can you please try any, simple, "hello world" text to test the welcome page?

Regards.

bro, this is my code https://github.com/xXCHINNAXx/SimpleLoginCodeigniter

I also tried with static pages

my base controller is Welcome.php

in that i have two functions
1. index
2.login


index is working fine and it is loading my static html page

but login is showing 404 error which is not loading my html page.


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - demyr - 06-01-2019

Well, If I'm not wrong in "login part" of your controllerWelcome.php you have got 3 openings of curly brackets, but 4 for closing. (starting line 21 and closing 42).

And also in your route file which is under config, please point to your login part of your controller :

$route['loginn'] = 'welcome/login';

And add this line under $router['default_controller] = 'welcome'; which is main route there now.


Regards.


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 06-01-2019

(06-01-2019, 08:43 AM)demyr Wrote: Well, If I'm not wrong in "login part" of your controllerWelcome.php you have got 3 openings of curly brackets, but 4 for closing. (starting line 21 and closing 42).

And also in your route file which is under config, please point to your login part of your controller :

$route['loginn'] = 'welcome/login';

And add this line under $router['default_controller] = 'welcome'; which is main route there now.


Regards.

bro, please solve the same problem for below code

Welcome.php

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

    
    public function 
index()
    {
        
$this->load->view('home.htm');
    }
    public function 
loginpg(){
     
   $this->load->view('login.htm');
    }
}
?>
routes.php

PHP Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['login'] = 'welcome/loginpg'
With this also getting same 404 error


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - demyr - 06-01-2019

Why you need a page ending with .htm on Codeigniter? You are working on Php  

PHP Code:
public function index()
 
   {
 
       $this->load->view('YOUR_VIEW/home');
 
   }
 
   public function loginpg(){
 
       $this->load->view('YOUR_VIEW/login');
 
   }
}
?>

then in the route please try: 

$route['the-url-on-the-browser(name-of-the-file-in-your-view)'] = 'welcome/-the-name-of-the-controller'


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 06-01-2019

(06-01-2019, 12:45 PM)demyr Wrote: Why you need a page ending with .htm on Codeigniter? You are working on Php  

PHP Code:
public function index()
 
   {
 
       $this->load->view('YOUR_VIEW/home');
 
   }
 
   public function loginpg(){
 
       $this->load->view('YOUR_VIEW/login');
 
   }
}
?>

then in the route please try: 

$route['the-url-on-the-browser(name-of-the-file-in-your-view)'] = 'welcome/-the-name-of-the-controller'
worked bro thanks


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 06-01-2019

problem solved
that was routing problem.


Thanks to all who spent their time helping me


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - chinna - 06-01-2019

(06-01-2019, 08:19 PM)chinna Wrote:
(06-01-2019, 12:45 PM)demyr Wrote: Why you need a page ending with .htm on Codeigniter? You are working on Php  

PHP Code:
public function index()
 
   {
 
       $this->load->view('YOUR_VIEW/home');
 
   }
 
   public function loginpg(){
 
       $this->load->view('YOUR_VIEW/login');
 
   }
}
?>

then in the route please try: 

$route['the-url-on-the-browser(name-of-the-file-in-your-view)'] = 'welcome/-the-name-of-the-controller'
worked bro thanks

bro getting another error

my url is https://www.everstore.com.au/testcod/test/index.php/loginn

it is redirecting to https://www.everstore.com.au/testcod/test/index.php/welcome/loginn
($route['loginn']='welcome/loginn';  i used this in routes.php)

and showing error
The page isn’t redirecting properly


An error occurred during a connection to www.everstore.com.au.

    This problem can sometimes be caused by disabling or refusing to accept cookies.


RE: 404 error from codeigniter when hosted to server (tried every possible conditions) - InsiteFX - 06-02-2019

It's redirecting right, look at your route.

controller/method
welcome /loginn