Welcome Guest, Not a member yet? Register   Sign In
Unable to load default controller on 404 errors.
#1

[eluser]sehummel[/eluser]
0 down vote favorite
share [fb] share [tw]


I'm having a strange problem. I'm getting an error for some pages (that don't exist and I'm trying them just to cause a 404 error and test this). What I should be getting is the 404 controller specified in the routes.php config file.

Here is my .htaccess:
Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] AddHandler cgi-script .pl

Could this be causing this? Anyone have a thought as to what could cause this? I have my base_url set to the proper domain. The problem seems to revolve around either the RewriteEngine and RewriteBase lines, but I can't figure out how to configure them. The issue doesn't seem to be in my routes. If I comment out all of them except the default controller and the 404_override, I still get the same error:

Quote:Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.
#2

[eluser]sehummel[/eluser]
I can post the routes file, but it is extremely long. I have commented it entirely out except for the default controller and the 404_override and I still have the problem. I tried your .htaccess file with and without the question mark and the problem still persists. Where else in my application could the problem be coming from? I am trying with a router name that doesn't exist (test). The whole purpose of this is to get the 404 page to load for controllers that don't exist, regardless of case.
#3

[eluser]pickupman[/eluser]
As I mentioned above, post the code for those values in your routes.php file. Also, what are the filenames of your 404_controller? Can you access the 404_controller via it's url?
#4

[eluser]sehummel[/eluser]
Yes, I can access the 404_override page via its controller. Here is the first part of my routes file. It is too long to post the whole things.

// Basic routes
$route['default_controller'] = "home/index_controller";
$route['404_override'] = "misc/site_map";
$route['(\w{2})'] = "home/index_controller";
$route['(\w{2})/(\w{2})'] = "home/index_controller";


// Channel partner routes
$route['cp/(\w{2})/([\w-]+)/(?!materials\b)(?!markets\b)(?!events\b)(?!news\b)(?!products\b)(?!misc\b)(?!thank-you\b)(?!resources\b)(?!open-houses\b)(?!open-house\b)([\w-]+)/([\w-]+)'] = "home/index_controller";
$route['cp/(\w{2})/([\w-]+)/markets'] = "home/markets";
$route['cp/(\w{2})/([\w-]+)/materials'] = "home/materials";
$route['cp/(\w{2})/([\w-]+)/markets/([\w]+)'] = "markets/$3";
$route['cp/(\w{2})/([\w-]+)/markets/consumer-goods'] = "markets/consumer_goods";
$route['cp/(\w{2})/([\w-]+)/markets/fabric-embroidery'] = "markets/fabric_embroidery";
$route['cp/(\w{2})/([\w-]+)/markets/general-manufacturing'] = "markets/general_manufacturing";
$route['cp/(\w{2})/([\w-]+)/markets/graphic-imaging'] = "markets/graphic_imaging";
$route['cp/(\w{2})/([\w-]+)/markets/identification-asset-management'] = "markets/security_id";
$route['cp/(\w{2})/([\w-]+)/markets/paper-goods'] = "markets/paper_goods";
$route['cp/(\w{2})/([\w-]+)/materials/([\w]+)'] = "materials/$3";
$route['cp/(\w{2})/([\w-]+)/laser-marking'] = "materials/laser_marking";
$route['cp/(\w{2})/([\w-]+)/laser-cutting'] = "materials/laser_cutting";
$route['cp/(\w{2})/([\w-]+)/laser-graphic-imaging'] = "materials/laser_graphic_imaging";
$route['cp/(\w{2})/([\w-]+)/laser-engraving'] = "materials/laser_engraving";
$route['cp/(\w{2})/([\w-]+)/materials/natural-materials'] = "materials/natural_materials";
$route['cp/(\w{2})/([\w-]+)/our-location'] = "channel_partners/our_location";
$route['cp/(\w{2})/([\w-]+)/open-house'] = "channel_partners/open_house";
$route['cp/(\w{2})/([\w-]+)/products/product-line'] = "products/product_line";
$route['cp/(\w{2})/([\w-]+)/products/pls6150d-superspeed'] = "products/products/pls6150d_superspeed";
$route['cp/(\w{2})/([\w-]+)/products'] = "products/products";
$route['cp/(\w{2})/([\w-]+)/products/(?!features\b)(?!1-touch-laser-photo\b)([\w-]+)'] = "products/products/$3";
$route['cp/(\w{2})/([\w-]+)/products/configure'] = "products/configure";
$route['cp/(\w{2})/([\w-]+)/products/features'] = "products/features";
$route['cp/(\w{2})/([\w-]+)/contact-us'] = "contact/contact";
$route['cp/(\w{2})/([\w-]+)/products/configurator/help'] = "products/configurator/help";
$route['cp/(\w{2})/([\w-]+)/applications-lab'] = "resources/applications_lab";
$route['cp/(\w{2})/([\w-]+)/products/accessories/(?!pin-table\b)(?!air-assist\b)([\w-]+)'] = "products/products/accessories/$3";
$route['cp/(\w{2})/([\w-]+)/laser-processes'] = "materials/laser_processes";
$route['cp/(\w{2})/([\w-]+)/news-events'] = "resources/news_events";
$route['cp/(\w{2})/([\w-]+)/financing'] = "resources/financing";
$route['cp/(\w{2})/([\w-]+)/resources'] = "home/resources";
$route['cp/(\w{2})/([\w-]+)/markets/([\w-]+)/gallery'] = "misc/gallery";
$route['cp/(\w{2})/([\w-]+)/materials/([\w-]+)/gallery'] = "misc/gallery";
$route['cp/(\w{2})/([\w-]+)/events/(\S*)'] = "resources/events_detail_page";
$route['cp/(\w{2})/([\w-]+)/news/(\S*)'] = "resources/news_detail_page";
$route['cp/(\w{2})/([\w-]+)/products/features/hpdfo'] = "products/features/hpdfo";
$route['cp/(\w{2})/([\w-]+)/products/features/platforms-lasers'] = "products/features/platforms_lasers";
$route['cp/(\w{2})/([\w-]+)/products/features/dual-laser'] = "products/features/dual_laser";
$route['cp/(\w{2})/([\w-]+)/products/features/pass-through'] = "products/features/pass_through";
$route['cp/(\w{2})/([\w-]+)/products/features/superspeed'] = "products/features/superspeed";
$route['cp/(\w{2})/([\w-]+)/products/features/laser-sources'] = "products/features/laser_sources";
$route['cp/(\w{2})/([\w-]+)/products/features/multi-wavelength'] = "products/features/multi_wavelength";
$route['cp/(\w{2})/([\w-]+)/products/features/laser-interface'] = "products/features/laser_interface";
$route['cp/(\w{2})/([\w-]+)/products/1-touch-laser-photo'] = "products/features/one_touch";
$route['cp/(\w{2})/([\w-]+)/products/1-touch-laser-photo/free-trial'] = "products/features/free_trial";
$route['cp/(\w{2})/products/1-touch-laser-photo-download'] = "products/features/one_touch_download";
$route['cp/(\w{2})/([\w-]+)/products/features/rapid-reconfiguration'] = "products/features/rapid_reconfiguration";
$route['cp/(\w{2})/([\w-]+)/terms'] = "home/terms_of_use";
$route['cp/(\w{2})/([\w-]+)/privacy-policy'] = "home/privacy_policy";
$route['cp/(\w{2})/([\w-]+)/products/product-line'] = "products/product_line";
$route['cp/(\w{2})/([\w-]+)/material-suppliers'] = "resources/material_suppliers";
$route['cp/(\w{2})/([\w-]+)/support'] = "service_support/support";
$route['cp/(\w{2})/([\w-]+)/misc/expert-contact'] = "misc/expert_contact";
$route['cp/(\w{2})/([\w-]+)/thank-you/contact-us'] = "misc/thank_you";
$route['cp/(\w{2})/([\w-]+)/products/configurator/select-power/([\w-]+)'] = "products/configurator/select_power/$3";
$route['cp/(\w{2})/([\w-]+)/products/configurator/select-platform'] = "products/configurator/select_platform";
$route['cp/(\w{2})/([\w-]+)/products/accessories/air-cart'] = "products/air_cart";
$route['cp/(\w{2})/([\w-]+)/products/accessories/air-assist'] = "products/air_assist";
$route['cp/(\w{2})/([\w-]+)/products/accessories/compressed-air-unit'] = "products/compressor";
$route['cp/(\w{2})/([\w-]+)/products/accessories/pin-table'] = "products/pin_table";
$route['cp/(\w{2})/([\w-]+)/submit-support-request'] = "service_support/support_request";
$route['cp/(\w{2})/([\w-]+)/faqs'] = "resources/faqs";
$route['cp/(\w{2})/([\w-]+)/downloads'] = "resources/downloads";
$route['cp/(\w{2})/([\w-]+)/open-houses'] = "channel_partners/open_house";
$route['cp/(\w{2})/([\w-]+)/open-house/([\d]+)'] = "channel_partners/open_house_detail/oh_detail/$1";
#5

[eluser]pickupman[/eluser]
I just used this and it worked.
Created file /application/controllers/misc.php
Code:
class Misc extends CI_Controller
{
    public function __construct()
    {
         parent::__construct();  
    }
    
    public function site_map()
    {
          echo 'Not Found';
    }    
}
Used url index.php/something and got 'Not found' on the screen.
#6

[eluser]sehummel[/eluser]
It's not working on mine, which means there is something messed up with my application. I downloaded the latest version of CI and upgraded, so it's not my system folder. Where in my application could the problem be coming from if it's not the routes. I've commented them out multiple times (except default and 404_override) and get the same error. Where else could this error be coming from?
#7

[eluser]pickupman[/eluser]
Are you using a custom Router class somewhere? Try placing this code in around /system/core/Codeigniter.php line 249.
Code:
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
   show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}

Change to:
Code:
var_dump(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'); //Add this line
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
   show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}

What is the file the Router class is looking for?
#8

[eluser]sehummel[/eluser]
I figured it out, thanks to you.

The var_dump showed me it was trying to load the folder name as the controller (misc/site_map => misc). Once I moved the site_map controller into the root of the controllers folder, it worked fine. Thanks, so so much!
#9

[eluser]pickupman[/eluser]
Whew...glad it was something simple. Smile
#10

[eluser]sehummel[/eluser]
Yeah, that was quite an ordeal. Thanks, again. I would never have figured it without the var_dump. This is something CI should fix.




Theme © iAndrew 2016 - Forum software by © MyBB