1

Now, when CodeIgniter does not find a controller for a route or a route for the uri, it shows a generic 404 page. How can I show the accessed route or controller or something useful that would allow me to debug why it's showed a 404?

Code:

switch ($_SERVER['HTTP_HOST']) {
    case 'multiplelines.domain.ro': 
             $route['default_controller'] = "subdomain"; break;
    default: $route['default_controller'] = "welcome"; break;
}


$route['scaffolding_trigger'] = "";
$route['404_override'] = '';
if($_SERVER['HTTP_HOST'] == "www.domain.ro" 
   || $_SERVER['HTTP_HOST'] == "domain.ro")
{
  // URI like '/en/about' -> use controller 'about'
  $route['^(romana|english|magyar)/(.+)$'] = "$2";

  // '/en', '/de', '/fr' and '/nl' URIs -> use default controller
  $route['^(romana|english|magyar)$'] = $route['default_controller'];
}
else
{

}

Desired effect: When on www or empty subdomain routing will occur like this: /language/test will go to test controller

When on another subdomain (I just listed one case) will be routing to the subdomain controller as I just want to use one controller for those.

Note: Now when on www or empty subdomain there is code to choose the language automatically for /test route for test controller (without language directory in uri).

Octavian
  • 4,519
  • 8
  • 28
  • 39

4 Answers4

1

When CI dont find correct Route for a page it knows that there isn't such page so it is giving 404 NOT EXISTING..

If user try to open /sgasgasggsasga page at your site it gets 404 for the same reason..

You have to find by yourself why its showing 404...

Look at http://codeigniter.com/user_guide/general/routing.html for help :)

Svetoslav
  • 4,686
  • 2
  • 28
  • 43
0

Enable error logging on your application.

Then, once you look up the errors, you will see the URI that was requested that generated the 404 error.

dakdad
  • 2,947
  • 2
  • 22
  • 21
0

Will fill in answer properly when on computer, but have a look at Debugging routes in codeigniter? it has route logging

Community
  • 1
  • 1
Hailwood
  • 89,623
  • 107
  • 270
  • 423
0
How can I show the accessed route or controller or something useful that would allow me to debug why it's showed a 404?

You could echo $_SERVER['REQUEST_URI'] in the 404 view to determine where the user was trying to go.

Max Power
  • 59
  • 1
  • 6