I am using CI3 HMVC in my project. Now, I am facing problem with routing. I want user to type www.demosite.com and it would automatically call my home module. I do not want to show like www.demosite.com/home. I want to show the url like www.demo.com. for this, I set default controller in application/config/routes, like this, as follows;
$route['default_controller'] = "home";
also in my content module, I added a route folder where I wrote
$route['home'] = 'home';
Here is my .htaccess
AddType text/x-component .htc
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !(index\.php|assets/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This is my home controller
class Home extends MX_Controller{
function __construct(){
parent::__construct();
}
function index($stub=""){
$baseUrl=base_url();
$this->load->helper("url");
echo $this->_showHomepage();
}
}
However, when I run this. I got 404 error. What can i do to solve this problem? Thanks in advance.
HMVC it should be like that
This only takes a method no directories are allowed so the default controller is under controllers
index is the default method that is called.
And than you need to change your .htaccess file to match that urls
URI Routing : https://codeigniter.com/user_guide/general/routing.html#examples
Update :