EllisLab text mark
Advanced Search
     
unable to call controller from URL
Posted: 27 September 2012 02:13 PM   [ Ignore ]
Joined: 2012-09-27
3 posts
<?php

class User extends CI_Controller {

 
function index() {
  $this
->load->view('login');
 
}

 
function userlogin() {
  
echo 'user [size=1][/size]is logged in';
 
}

}
?> 

This is my code and I am unable to call User controller. When I am accessing like this
http://localhost/learning/User

I am getting error as Not Found
The requested URL /learning/User was not found on this server.

Please help me..

 

 
Posted: 27 September 2012 02:22 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-12-19
612 posts

Try this URL:

http://localhost/learning/index.php/user 

NOT capitalized, with index.php

 Signature 

CI 2.1.3, Linux, LAMP. We also like Gold and Silver…
Blame the hammer, it is obviously the guilty party…
User Guide? Nobody told me there was a User Guide!

 
Posted: 27 September 2012 10:00 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-09-27
3 posts

smile Thats working good. Thankyou very much. But how it works ? is there any other solution with out using index.php

once again thanks..

 
Posted: 30 September 2012 11:35 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2012-09-30
5 posts

You can use htaccess redirect. Why index.php is involved by default I have no clue.
In your htaccess in root

RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
.* index.php/$0 [PT,L] 
 
Posted: 03 October 2012 12:49 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-09-27
3 posts

Thankyou for your response but when I placed that code in .htaccess file and copied that place in root folder. But I am facing problem like this.

Error:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

please help me.

 
Posted: 03 October 2012 01:19 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

Does your server have mod_rewrite enabled?  It needs to be in order to use rewrite rules.

 Signature 
 
Posted: 03 October 2012 01:20 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts
Bankzilla - 30 September 2012 11:35 PM

You can use htaccess redirect. Why index.php is involved by default I have no clue.

Because it will work 100% of the time with index.php, but not all servers have mod_rewrite (or allow customers to alter) so if that was the default it wouldn’t work out of the box on those servers.

 Signature