1

I need some help to configure Codeigniter on my free hosting.

I'm using CodeIgniter 3.0 and Hostinger for my website.

I have my config.php as:

    $config['base_url'] = 'http://mysite/';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';

And I configure the .htaccess as said in this topic: Codeigniter website 404 error / .htaccess

   RewriteEngine On
   RewriteCond %{REQUEST_URI} ^/system.*
   RewriteRule ^(.*)$ index.php?/$1 [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.+)$ index.php?/$1 [L]

And even with this I still get the 404 Page not found from Codeigniter, what am I missing? or what am I doing wrong? I'm new in this so if you need to see something else tell me and I'll upload it. Thanks!

EDIT: I forgot to mention that in my localhost is working, but on live is when I get the 404 Error.

Community
  • 1
  • 1
Jose
  • 21
  • 1
  • 5
  • Can you check if the apache rewrite module is enabled? Assuming you are using apache – Jacob Mar 29 '15 at 19:04
  • In questions done to Hostinger directly it says that the mod_rewrite is enable by default: http://www.hostinger.ph/knowledge-base/99.html – Jose Mar 29 '15 at 19:11
  • Have you set a default controller? – Jacob Mar 29 '15 at 19:14
  • Yes. In localhost is working fine, but on live it gets me the 404 Error. – Jose Mar 29 '15 at 19:19
  • Can you see what your httpd.conf has for it's DocumentRoot & Directory, or rather what the Vhost for this particular website is? – Jacob Mar 29 '15 at 19:20
  • It seems like Hostinger doesn't allow to modify the httpd.conf because it is a shared hosting service /: – Jose Mar 29 '15 at 19:30

3 Answers3

1

Thanks to the assistance of Ajeet Kumar we manage to find the error:

It seems like it was a problem of case sensitivity on the Hostinger file system that it wasn't failing on my localhost.

Always remember to name your Controllers and Models files with upper case at the beginning.

As I said before, I'm new in this and didn't thought of that because my localhost was working fine. Thanks to everyone for your assistance.

Jose
  • 21
  • 1
  • 5
0

In .htaccss file write this code

  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ index.php?/$1 [L]

<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>

in Config.php

$config['base_url'] ="YOUR_SITE_URL";//http://example.com/
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';

$config['encryption_key'] = 'SET_ANY_KEY_TO_USE_SESSION';

And database.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'DB_USERNAME';
$db['default']['password'] = 'DB_PASSWORD';
$db['default']['database'] = 'DBNAME';
$db['default']['dbdriver'] = 'mysql';
Ajeet Kumar
  • 805
  • 1
  • 7
  • 26
  • Nope, stills the same :c – Jose Mar 29 '15 at 19:25
  • I got the 404 default error screen from CodeIgniter, I check the logs folder of CodeIgniter and it doesn't show anything /: – Jose Mar 29 '15 at 19:32
  • in config.php file $config['log_threshold'] = 4; and then check log – Ajeet Kumar Mar 29 '15 at 19:35
  • ERROR - 2015-03-29 19:38:30 --> 404 Page Not Found: /index – Jose Mar 29 '15 at 19:39
  • Your default controller is set in route ?$route['default_controller'] = "welcome"; Check this also http://stackoverflow.com/questions/18166496/routes-in-codeigniter-404-page-not-found – Ajeet Kumar Mar 29 '15 at 19:47
  • Actually, when I set my default_controller to welcome, it works fine, but when I set to the main controller of the website it gets 404 error O: – Jose Mar 29 '15 at 19:54
  • That means your codeigniter working correctly. check your controller is accessible or not(you writing correct conroller,controller name cannot contain the spaces) – Ajeet Kumar Mar 29 '15 at 20:03
  • I found the error, it seems like Hostinger file system has some issues with the case sensitivity, because I don't have that issue in my localhost, if the files called in the controller doesn't have upper case in the beginning, it won't recognize it, thanks for the help. – Jose Mar 29 '15 at 20:07
-2

Error de .htaccess como se dice en este tema: Codeigniter sitio web 404 error / .htaccess... pues solo reemplazen con esto script .htaccess Funcional 100 x 100 en los hostings

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]
Pang
  • 9,564
  • 146
  • 81
  • 122
  • 2
    [so] is an English-only site. Please post in English. [See here](https://meta.stackexchange.com/q/13676/204869), [here](https://meta.stackoverflow.com/a/262054/1402846), and [here](https://blog.stackoverflow.com/2009/07/non-english-question-policy) for details. Thank you. – Pang Jun 10 '17 at 01:47