Search code examples
phpcodeignitercodeigniter-2codeigniter-urlcodeigniter-routing

CodeIgniter show accessed route/translated controller on 404 page


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


Solution

  • 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 :)