CodeIgniter Forums
404 not found! - 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: 404 not found! (/showthread.php?tid=70256)

Pages: 1 2


RE: 404 not found! - richb201 - 03-16-2018

The way it is working (and that part does work OK) is when I type localhost in the browser, the Users controller with the login function is running.

The question is "without modifying the default controller is there anyway for me to access function register() in Subit_backend.php from a xhr Extension"? I modified Subit_backend to be:

class Subit_backend extends CI_Controller
{

   public function __construct()
   {
       parent::__construct();

       $this->load->database();
       $this->load->helper('url');
         }


   public function register()
   {

   }
}

but when i type localhost/Subit_backend.php/register or localhost/Subit_backend/register or even just localhost/Subit_backend from the browser address bar I still get Error 404.

Can i assume that when I type localhost/Subit_backend/register I am actually typing c:/xampp/htdocs/Users/login/subit_backend/register ?


RE: 404 not found! - ciadmin - 03-16-2018

No. the default controller is *only* executed if your original URL maps to a folder without an explicit controller identified.

localhost/subit_backend.php/register will look for a subit_backend.php file in your document root.
localhost/subit_backend/register will look for a Subint_backend controller inside application/controllers, and will try to invoke its register method.

It sounds like you would benefit from carefully re-reading the CI user guide sections on routing.


RE: 404 not found! - richb201 - 03-17-2018

I read it and found a section called "Using HTTP verbs in routes". So I will try:

$route['subit_backend']['GET'] = 'subit_backend/register';

I am hoping that this will invoke subit_backend::register.

Btw, this did not work! I get the same 404.

I am hoping to invoke the register method in the Subit_backend controller when I call

 xhr.open("GET", "http://localhost/Subit_backend/register", true);

I am concerned that this is not a problem with the ci backend, but is instead a problem with the xhr.open or the client permissions. Do you know of any way to prove which part is the problem so I can zero in on that problem?


RE: 404 not found! - jreklund - 03-17-2018

I'm starting to suspect that you get a true 404 error message and not just Codeigniters 404.

Just to clarification, can you access your user/login with the following URL:
localhost/user/login

If not, does it work with the following URL?
localhost/index.php/user/login

If it does, you need to do these steps to get rid of index.php
https://www.codeigniter.com/user_guide/general/urls.html#removing-the-index-php-file

After that the following url should start working:
localhost/subit_backend/register

Instead of:
localhost/index.php/subit_backend/register


RE: 404 not found! - richb201 - 03-17-2018

Yes. there are definately two different 404 messages (I don't know which one is the CI one). I have attached each showing what address led to it. Do you still think I should remove index.php after seeing this?


RE: 404 not found! - jreklund - 03-17-2018

"404 Page Not Found" = Codeigniter
"Object not found!" = Apache/Webbserver error

Either you remove index.php with the link provided above or you need to include index.php in ALL your urls:
localhost/index.php/subit_backend/register
localhost/index.php/user/login (or users/login, as I made a typo on your controllers name)
etc...


RE: 404 not found! - richb201 - 03-18-2018

Well, that seemed to work! Thank you so much. I haven't managed to get the callback from the xhr.send (in the Extension)working yet, but at least I don't get a 440 error anymore!


RE: 404 not found! - InsiteFX - 03-18-2018

Here is a good read on XHR:

MDN mozilla - XMLHttpRequest (XHR)