Hi I’m developing a CodeIgniter application that gives user their own website.
What I’m trying to accomplish: If a user has an account they have their own subdomain (ex: user.website.com), and the default controller becomes ‘user_website’, if the website is accessed normally (no subdomain) the default controller is ‘website’.
When the user accesses their section I have a method for example called ‘test’
So to access that the user would go to:
user.website.com/user_website/test
What I want to happen is:
user.website.com/test
So basically what I’m asking is how can I get codeigniter to if there is a subdomain in use access methods for the controller directly without having to put the controller in the url.
So instead of user.website.com/auth going to the auth controller, it would use an auth method of the user_website controller
If anyone can help me out on how to accomplish this, or point me in the right direction, thanks in advance.
Also here is _remap function from MY_Controller which all my controllers extend.
public function _remap($method, $arguments)
{
if (method_exists($this, $method))
{
call_user_func_array(array($this, $method), array_slice($this->uri->rsegments, 2));
}
else
{
show_404(strtolower(get_class($this)).'/'.$method);
}
$this->_load_view();
}
You can try a route, but what you are asking might be to complex. I have routes like this
so if someone goes to user.website.com/test, it will route them to the controller user_website and call the method test, is that what you were looking for?