CodeIgniter Forums
Default Controller doesnt work on base url. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: Default Controller doesnt work on base url. (/thread-78706.html)



Default Controller doesnt work on base url. - danielu_ci - 02-28-2021

Hi there,

Just a little help, I already setup most of the things I need in CI 4.1.1. I'm mounting it on a cPanel hosting, and I've already managed to remove the index.php/public from the url. The only problem I can't seem to resolve is to load the default controller when visiting the base url of my application.

I already defined the base url and removed the indexPage on the Config/App.php as the documentation says.

PHP Code:
public $baseURL 'http://domainexample.com/';
public 
$indexPage ''

And in my Config/Routes.php

PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
//
//$routes->get('/', 'Home::index'); 


So if I visit domainexample.com it doesn't load anything, while domainexample.com/home it loads the page correctly. (it does no difference if I uncomment the routes->get('/', 'Home::index'); line
I'm using a subfolder to separate admin from public page, and if I visit domainexample.com/admin,it loads the home controller in the admin subfolder correctly so the configuration is working.
I'm using the default .htaccess provided in the CI folder on my root directory, I pulled it out of the public folder.

Am I missing a configuration or why doesn't it load nothing when visiting the base url?

Thanks in advance.


RE: Default Controller doesnt work on base url. - remesses_thegreat - 03-01-2021

In your .htaccess file specify the subfolder by using RewriteBase /subfolder