![]() |
CodeIgniter with multiple subdomains - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CodeIgniter with multiple subdomains (/showthread.php?tid=69658) |
CodeIgniter with multiple subdomains - waqaskhanbhatti - 01-01-2018 Hi to all members, I have a problem and hopefully we will solve it. The problem is, I am creating an application this application has an “Admin Panel (Backend)” and Frontend. The URL structure of the admin panel is like this https://www.app-name.com/admin For frontend I have a different URL structure which is based on country for example. https://usa.app-name.com https://ca.app-name.com https://uk.app-name.com https://uae.app-name.com https://in.app-name.com It means in frontend I have multiple sub-domains. And the all these sub-domains are sharing a single database. As well as, backend is also sharing the same database. Now my problem is how can I handle front-end like this. Possible one solution in my mind is to copy app to all the sub-domains and connect with single database. And for admin panel copy it at the main domain. But in this case, if I have a single modification to application I have to update all the copies. I want to use only single copy of app to handle all sub-domains. Anyone have some solution for this problem. Thanks RE: CodeIgniter with multiple subdomains - XtreemDeveloper - 01-01-2018 As per your requirement you need to added a unique field for subdomain. And another option for you, you can make multiple tables as per subdomain for manage the content as per subdomain.
That said my solution, for those who may stumble across it is, in the routes.php I ended up making a small function to get the HTTP_HOST split it up based on . and use it from there to my needs. My example is as follows. Mind you I also replaced everything in the routes.php so its not just a straight line of $route['this/that'] = 'dir/controller'; Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); RE: CodeIgniter with multiple subdomains - waqaskhanbhatti - 01-01-2018 (01-01-2018, 11:09 PM)Thanks for your reply,In database I have a separate field for each country to get data for specific country. I understand the routing modification. you are getting the host and then split it by fining "." in the name of the host and the results stored in an array. so at the 0 index of the array you have sub-domain name. But I\m confused about how to upload application on server. for each sub-domain I need to upload this application. Infect I Wrote: |