简体   繁体   中英

Codeigniter Controller class login form : 404 page not found

Im trying to combine several tutorials about Codeigniter and bootstrap and understand per codes so i can integrate it in my project. What i am trying to do right now is create a login form using the two framework.

And i setup my View according to the turotial included in Codeigniter 'user_guide/tutorial/static_pages.html' which my landing page is named as 'home.php' is inside the folder 'pages' and header.php, and footer.php is inside the 'templates' folder. I created also a controller: Page.php.

I also use .htaccess to hide 'index.php'. Now i follow this tutorial how to create a login page: http://learnjquerybootstrap.blogspot.com/2015/01/login-session-using-codeigniter-and-bootstrap.html?m=1

-the only difference is this since i use htaccess:

<?php echo form_open(clogin/index); ?>

But when I try to submit the page i receive a: 404 page not found. My navbar links are working fine. I understand that the codeigniter works like this:

http://localhost/myfolder/index.php/class/function/

so when i submit my form the url that show up is:

http://localhost/myfolder/clogin/index

and gives me: 404 page not found.

Question: What is wrong with it? is there something wrong with the tutorial that i am using? i check other tutorials and the controller structure is just the same, like on this link:

http://www.kodingmadesimple.com/2014/08/how-to-create-login-form-codeigniter-mysql-twitter-bootstrap.html

do i need to include clogin.php in route.php? or is it about the htaccess? my

uri_protocol

is configured as

'REQUEST_URI' 

in config.php. i tried other options but still the same.

Don't need include to route. I recommented ready auth library. If you use DevTools in your browser maybe "Network" tab of devtools can help you to why you get 404 error.

i already firgured it out.The mistake was in the route.php, since i tried to combine two examples.. i realized that the wildcard route that i included from the Codeigniter user guide will not work with the Clogin.php.

Since it was set as

$route['(:any)']='pages/view/$1';

So the url works as

http://localhost/myfolder/pages/view/clogin

instead of

http://localhost/myfolder/clogin .

I removed it and now it is working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM