Welcome Guest, Not a member yet? Register   Sign In
No URI present. Default controller set
#1

My routing is not working. 

I removed the index.php with - https://github.com/bcit-ci/CodeIgniter/w...or-Windows

I am using the following settings:
Fresh copy of codeigniter 3.1.9
```php
config.php 

$config['base_url'] = 'http://localhost/CodeIgniter-3.1.9/';
$config['index_page'] = '';


.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

routes.php

$route['hello/(:any)'] = 'hello/$1';

controller - Hello.php

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

class Hello extends CI_Controller {

public function __construct(){
parent::__construct();


}
public function index()
{
echo("Hello - index");

$this->load->view('welcome_message');

}

public function hello(){
echo("hello");
$this->load->view('welcome_message');
}


}

When I navigate to http://localhost/CodeIgniter-3.1.9/hello it's loading the Welcome controller. 
logs: 
DEBUG - 2018-08-24 18:56:47 --> UTF-8 Support Enabled
DEBUG - 2018-08-24 18:56:47 --> No URI present. Default controller set.
DEBUG - 2018-08-24 18:56:47 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-08-24 18:56:47 --> Total execution time: 0.0227
```
Reply
#2

That's my bad, I turned on $config['enable_query_strings'] = TRUE; in config that's why it's causing the issue. When I was reading the core uri.php file then it has following comment.

// If query strings are enabled, we don't need to parse any segments.
// However, they don't make sense under CLI.
if (is_cli() OR $this->config->item('enable_query_strings') !== TRUE)
I set $config['enable_query_strings'] = FALSE; then everything working fine.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB