CodeIgniter Forums

Full Version: Codeigniter shared hosting 404 error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I am working with codeigniter 3.1.X.Everything is fine in localhost.All working normal with controllers and views.But when i hosted my application in hostgator cPanel the controllers stopped working and 404 error giving.The default controller working but no other controller is working.My .htaccess of application folder is as follows 

<code>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

it is very fine working in local host in all systems but not when hosted through Cpanel. Please help me in this regard i have tried REQUEST_URI index page  index.php.

I have checked for Mod_rewrite enable and it is also fine


</code>
I have shared hosting and my CodeIgniter runs just fine.

Check to see if it is expecting all lower case filenames etc;
Leave out the "RewriteBase /" or put a # at the beginning of that line.
The most common reason why "it works on localhost, but gives 404 on the live site" is a failure to follow CodeIgniter's file naming requirements.
  1. The first character in the file names of Controllers, Libraries, and Models MUST be uppercase
  2. All other characters in the file name must be lowercase
  3. File names and Class names must be exactly the same

This happens a lot to devs where localhost is no a Windows system and the live server is Linux. The first OS is a case-insensitive, but the later is case-sensitive.
(05-15-2019, 07:10 AM)dave friend Wrote: [ -> ]The most common reason why "it works on localhost, but gives 404 on the live site" is a failure to follow CodeIgniter's file naming requirements.
  1. The first character in the file names of Controllers, Libraries, and Models MUST be uppercase
  2. All other characters in the file name must be lowercase
  3. File names and Class names must be exactly the same

This happens a lot to devs where localhost is no a Windows system and the live server is Linux. The first OS is a case-insensitive, but the later is case-sensitive.
But I have tried all..nothing working
it is worked once if i changed .htaccess of root folder o the following

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and changed in config.php
Code:
$config['index_page'] = '';

but only one request it worked fine and total site is hanged..even now home page or any static page is also not working.
 any body help
@srmarasu84,

Can we see the model, view and controller for one of the pages that is receiving a 404 error?
Thank god finally it worked..adding .htaccess in root folder is required and no need to add index.php in url.


It is working fine now..thanks to all for quick replies