2
votes

I don't usually post messages on the web to get help but I feel that I have tried everything and I am stuck.

I wanted to upgrade CodeIgniter from version 2.2 to version 3.0.3 (I tried v3.0.2 too) and I followed the corresponding guide on codeigniter.com. But now, only the default controller is loaded, no matter the url.

I have searched on the web and I have found out that it could come from:

  • the htaccess
  • the application/config/config file
  • the application/config/routes file
  • the new Ucfirst rule for the filenames (controllers, models...)

But I still don't have the solution...

  • The files in "applications/controllers" are all Ucfirst.
  • Everything was working fine before (with version 2.2), so WAMP should be correctly configured (mod_rewrite enabled etc...). Moreover, I have tried and succesfully loaded a clean instance of CodeIgniter 3.
  • Models, Controllers and Views are loaded correctly, I can change my default controller and it will load the correct view (with requests done by controllers and models). But it only loads the default controller, no matter what the url is (in the browser). Even if it does not exist, I never have the 404 page. Except if I specify an incorrect "default_controller" (in the file "routes.php").

It has to be a routing issue...

Here is some of the tests I have done: Table of tests

Here is my htaccess file (I have tried other ones on the web too, the result is the same):


    
    RewriteEngine On

    #Checks to see if the user is attempting to access a valid file,
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Enable access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]
    

Here is my "application/config/routes" file:


    $route['default_controller'] = 'dashboard';
    $route['404_override'] = 'auth/e404';
    $route['translate_uri_dashes'] = FALSE;

Any help would be appreciated :-)

Thank you !


SOLUTION

$config['enable_query_strings'] was set to "TRUE" in the file "application/config/config.php". Setting it to "FALSE" solved the issue. So simple...

2

2 Answers

0
votes

try putting the index method in the routes, for example instead of this

$route['blog'] = 'blog';

try this

$route['blog'] = 'blog/index';

and if that doesn't work, can you confirm you have set the correct base url in application/config/config.php ?

0
votes

In codeigniter 3 wamp

I use this htaccess

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

With your error 404 over ride can not be in sub folder.

Change

$route['404_override'] = 'auth/e404';

To

$route['404_override'] = 'e404';

And on config.php

$config['base_url'] = 'http://localhost/your_project/';

// You can leave base url blank but not recommended because when you try to submit forms make cause issue.

$config['index_page'] = '';

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