Is there any point in the execution of CodeIgniter where I can get data from MySQL through HTTP_HOST and use and set the base_url retrieved so that the correct routing is enforced?
I didn’t have any problem with running this under the hook event post_controller_constructor when I only used sub.domain.com and domain.com, but I this problem when I wish to have base_url as domain.com/folder/.
My Codeigniter has already decided which controller to load, and changing the base_url doesn’t fix it.
From my knowledge, I can’t do MySQL commands before the hook event post_controller_constructor, which I guess I must be able to do since base_url should be set before routing occurs.
So basicly, is there any efficient way to either reroute in middle of the execution, or to run mysql before routing occurs?
Update
Seems like I was on the wrong track.
Here’s the scenario:
I have one CodeIgniter package/set. At the moment I use it through multiple domains and subdomains. My CodeIgniter loads relevant profile based on HTTP_HOST. I’ve made it to also load relevant profile in case it contains a folder to the domain. The problem is that the routing occurs and see’s the folder as a part of the controller/routing instead of the base_url.
With the address http://domain.com/folder/admin I want the controller admin loaded (inside controllers/), not the controller folder.
In some way I want to draw the conclusion that the entire part of the base_url will be excluded in the routing process.
It’d be similiar to $route['\w+/(.+)'] = '$1'; but based on MySQL.
base_urlhas nothing to do with routing, only URLs.You can use a
pre_controllerhook,post_controller_constructorhook, or run it in a base controller__construct(such asMY_Controller).It’s this easy:
Functions like
base_url()read from the CI$configarray, so you can change it at any time.