0

I'm new to codeigniter and MVC's in general. I have a site that has been functioning fine for the past few months however after setting up a mobile version of it, I realized that the site fails to load on mobile devices. I get an error message that says "Unable to load the requested file: mobile.php"

The same issue occurs for the desktop version of the site where I use a file called default.php. As far as I can remember, the desktop version originally loaded on mobile. The only changes I made was added a few new files to the views in a new directory called mobile and set up a new controller. I tested loading the desktop and mobile version on 2 separate desktops so I don't think there's a caching issue going on. I can't think of any reason why this will load on a computer but not a phone.

Here's my controller.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mobile extends CI_Controller {

public function __construct() {
    parent::__construct();
        $this->load->library('template');
}
public function index(){    
    $this->template
        ->set_layout('mobile.php')
        ->title('T.E.B')
        ->build('mobile/index.php');
}
}

EDIT::

I took a look at the routes.php files and added another line for mobile but that hasn't changed anything.

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['mobile/(:any)'] = 'mobile';
4
  • Try Checking the routes.php config ensure that when browsing from a mobile you are getting the URL you would expect if not try adding a default route into the config Feb 20, 2014 at 18:23
  • How can I tell if the routes.php file has any errors? I updated my code above to include the routes.php contents Feb 20, 2014 at 18:41
  • I'm not sure why, but for some reason changing the controller's name to anything other than mobile along with the directory for the views fixed everything Feb 20, 2014 at 19:10
  • I feel your pain I have an issue with CI routing when using https:// - if you find anything please post back. Feb 22, 2014 at 18:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.