Welcome Guest, Not a member yet? Register   Sign In
[NEED URGENT HELP] All controllers showing 404 except default controller
#11

(05-16-2015, 05:37 AM)karthik_code Wrote: Can you able to access directly?
example.com/index.php/controller/method

No. I can only asscess-
example.com
example.com/faculty-member
example.com/registration

where faculty-member & registration are methods of my default controller.

But I cannot access
example.com/student

or
example.com/student/profile

Where student is another controller.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#12

(05-16-2015, 05:42 AM)Muzikant Wrote: Just blind guess - Try to add "RewriteBase /" to your .htaccess file:

Code:
RewriteEngine On
RewriteBase /
...

Or try any of these:
.htaccess for CodeIgniter

Nothing


Code:
RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#13

(This post was last modified: 05-16-2015, 06:07 AM by Muzikant.)

Another blind guess - When you created new controller, you probably make it by copying content from your main controller. Did you rename controller class as well?

For example in your Student.php file could be the wrong class name:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Home extends CI_Controller 

"class Home extends CI_Controller {"
Reply
#14

(05-16-2015, 06:02 AM)Muzikant Wrote: Another blind guess - When you created new controller, you probably make it by copying content from your main controller. Did you rename controller class as well?

For example in your Student.php file could be the wrong class name:

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

class 
Home extends CI_Controller 

"class Home extends CI_Controller {"

Please take a look at my main post. As I said before-

Quote:It is working without any error on my localhost
so there is no chance for this type of error.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#15

From your initial statement : You have stated that the application works perfectly in your developer machine (might be Windows) and not working on live server (might be Linux).

I guess there should be a server side configuration issue.
1. If you are using Windows machine for development, case sensitivity issue may come for File names, class names for the same code in Unix/Linux server.
2. If you can access the methods directly by including 'index.php', there may be an issue with Apache configuration - Directive 'Allow Override All' may be missing in apache conf file.


Other troubleshooting tips:
1. Remove .htaccess and try to access the controllers and methods directly without the help of mod_rewrite.
2. Remove & Add the rules one by one in routes, it may help you to detect the controller or rule which causes the issue.
Reply
#16

(This post was last modified: 05-16-2015, 03:54 PM by CroNiX.)

Try this htaccess
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

When you say it works on localhost but not on server...and "so there is no chance for this type of error."... That is absolutely not true unless your server has the exact same OS, webserver, modules, php version, php modules, setup, etc as your development server which most likely isn't the case unless you're using a virtual machine or something. Some OS's are case sensitive when it comes to filenames and others aren't.
Reply
#17

I think the problem is the new naming convention which enforces UCfirst Controller Filenames (and Classnames!). This error will not occur on windows machines where there's no difference in (un)capitalized filenames. So if your controller is named student.php rename it to Student.php. Same convention for libraries i believe.

Excuse my poor english - non native speaker...

Cheers Thorsten
Reply
#18

(This post was last modified: 09-14-2018, 03:19 AM by ciadmin.)

(05-16-2015, 02:16 AM)webdevron Wrote: try using index.php before adding your controller's name
build url in this format : domain name/index.php/controller'name/method in controller/parameters 
example : http://example.com/index.php/student/ 
PHP Code:
$route['default_controller'] = "home";

$route['(:any)'] = 'home/$1'   // http://example.com/any
$route['load/(:any)'] = 'home/load/$1' // http://example.com/load/any

$route['student'] = 'student' // http://example.com/student
$route['student/(:num)'] = 'student/profile/$1' // http://example.com/student/1234

$route['admin'] = 'admin' // http://example.com/admin
$route['admin/(:any)'] = 'admin/$1' // http://example.com/admin/any 
My .htaccess code is here

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB