Reputation: 502
I have been developing a small web application with CodeIgniter. After testing it out locally I went to put it on my web server to allow a couple other people test out some features. While navigating to the site I get: -
404 Page Not Found error page
When viewing it in my local machine everything loads up and runs perfectly.
This is what I uploaded to the public_html
directory:
application directory
system directory
assets directory (my assets for the site)
index.php
All of those are in the public_html
directory. Like I said, it does give me CodeIgniters 404 error page, so I do know it is at least seeing CodeIgniter. I also tried changing the $config['base_url']
, in the config.php
, to my URL. Same error when changing that or leaving it blank.
I checked my routes, and all those seem correct. Everything also loads up just fine when navigating to it on my local machine.
I also am not using a .htaccess
file at this time
Any suggestions on what I should try?
Thanks a lot!
Upvotes: 39
Views: 187203
Reputation: 906
Add following line in root folder index.php just after <?php starts:
ob_start();
Upvotes: 0
Reputation: 901
There are a number of things you can check here. I'll go over each one with you.
1, When moving to a live server from localhost(htdocs) you need to make sure that the version of PHP you are using is supported.
To test this: Create an 'index.php' file and add the below line only.
<?php phpinfo(); ?>
Just press 'Ctrl + F' and search "version". You will find the php version. It may need to be 5.3+ to support features.
2,
Check your config/config.php
and check your $config['base_url']
and $config['index_page']
screen shot below
I recommend putting site name in the base url example: 'www.site.com/
'
but remove the index.php for cleaning.
3, MOST LIKELY THE REASON SO START WITH THIS
It most likely is the .htaccess file. Here is mine Made by Elliot Haughton. Put this in your root directory and change line 9 'RewriteBase /' if necessary.
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
If none of the above works, give me a shout back and we'll step through it.
Upvotes: 18
Reputation: 664
Changing the first letter to uppercase on the file's name and class name works.
file: controllers/Login.php
class: class Login extends CI_Controller { ... }
The file name, as the class name, should starts with capital letter. This rule applys to models too.
https://www.codeigniter.com/user_guide/general/models.html
Upvotes: 18
Reputation: 47
Try to add following line in root folder index.php after php starts:
ob_start();
This works for me.
Upvotes: 1
Reputation: 354
I was stuck with this approx a day i just rename filename "Filename" with capital letter and rename the controller class "Classname". and it solved the problem.
**class Myclass extends CI_Controller{}
save file: Myclass.php**
application/config/config.php
$config['base_url'] = '';
Upvotes: 5
Reputation: 123
I have solved this problem, please just make few changes
1- all controller class name should start with capital letter. i mean first letter of class should be capital . eg we have controler with class name Pages
so it should be Pages not pages
2- save the controller class Pages as Pages.php
not pages.php
so first letter must be capital
same for model, model class first letter should be capital and also save model class as Pages_model.php
not page_model.php
hope this will solve ur problem
Upvotes: 12
Reputation: 4510
I am doing it on local and production server this way:
Routes:
$route['default_controller'] = 'Home_controller';
Files' names:
Home_controller.php:
class Home_controller extends CI_Controller {
public function index(){
//loading Home_model
$this->load->model('Home_model');
//get data from DB
$data['db_data'] = $this->Home_model->getData();
//pass $data to Home.html
$this->load->view('Home', $data);
}
}
Home_model.php:
class Home_model extends CI_Model {
...
}
There should be no more problems with cases anymore :)
Upvotes: 3
Reputation: 2222
Please check the root/application/core/
folder files whether if you have used any of MY_Loader.php
, MY_Parser.php
or MY_Router.php
files.
If so, please try by removing above files from the folder and check whether that make any difference. In fact, just clean that folder by just keeping the default index.html file.
I have found these files caused the issue to route to the correct Controller's functions.
Hope that helps!
Upvotes: 0
Reputation: 1034
You are using MVC with OOPS Concept. So there are some certain rules.
1) Your class name (ie: controller name) should be start with capital Letter.
e.g.: your controller name is 'icecream'. that should be 'Icecream'
In localhost it might not be compulsory, but in server it will check all these rules, else it can't detect the right class name.
Upvotes: 101
Reputation: 171
I had the same problem. Changing controlers first letter to uppercase helped.
Upvotes: 14