Reputation: 233
In CodeIgniter, is there a way to know if a user was sent to the Default Controller because the route sent them there, OR because the user actually entered that controller in the URL bar.
In other words, ---.com/home and ---.com could both send you to the 'home' controller, because you have set
$route['default_controller'] = 'home';
But only ---.com/ would invoke CI to fetch the "default_controller" So, how do I detect this? If only there was a boolean function that could tell me this.
Upvotes: 1
Views: 1897
Reputation: 3273
You should be able to use $this->uri->total_segments()
... or one of the other functions in the URI class to deduce this ...
if($this->uri->total_segments() === 0){
//user came in by default_controller
}
Upvotes: 6