CodeIgniter: Solution to 404 Page But First Page

Several times ago, i got this error while i was using CodeIgniter framework:

  • i can only access the page that redirected right in controller constructor, but the rest of it yields 404 page.
  • when i use localhost to test the website, it runs fine. But these sicknesses happened when i try to migrate the code to hosting.

when i googled it, a lot of forum adviced that i should check my config.php. the kind of error may vary, maybe you can be safe with this one. try to change several options of code below, maybe you can get luck with one of them. Most had luck with this way:

$config['uri_protocol'] = "REQUEST_URI";

after a couple of googlings, finally i got the answer. It’s just a matter of .htaccess redirecting. We can add similar code like this in .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt|foto|js|css|public)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

you can find .htaccess file in your /public_html/. sometimes, it can be the web hosting hide the file, so you have to make it appears first (if you don’t know, i advice some googling).

it worked for me. Cheers. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s