![]() |
How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) (/showthread.php?tid=34642) |
How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-05-2010 [eluser]Juan Velandia[/eluser] Hello Everyone, I am trying to use a CI deployment with two different domains, the thing is that I need to change certain elements of the website depending on the domain (ie. logo). Do you have any ideas how to change the base_url according to the domain? perhaps you would like to have a look: http://www.segurosinmobiliarios.com.co/ http://www.searrienda.com.co/ they both are pointing to the same Ci deployment Any help would greatly appreciated!, thanks in advance JuanK How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-05-2010 [eluser]Nick_MyShuitings[/eluser] I am not sure where I grabbed this from... but this little piece of code has made my life so much easier. It lets me not have to change the base_url variable when I deploy the site, or with subdomains etc. Now, how you take it from there to show a different logo is a different issue... I place this code in my constants.php config file. I use it to make life easier when hosting multiple applications on one codebase. Code: /* How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-05-2010 [eluser]cahva[/eluser] Something like this in config.php (this is not mine, got from some thread and used succesfully): Code: $config['http_https'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http'; That will work with any domain or subdomain that is pointing to your directory in virtual hosts. Plus as a bonus takes account if the url is secure(https) or not. With that it would be quite trivial to change the logo depending on base_url(or straight with $_SERVER['HTTP_HOST']) on the page for example. How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-05-2010 [eluser]Nick_MyShuitings[/eluser] Yeap, that is virtually identical to what I use... but I kinda like keeping it out of config.php... wherever I snagged it from had a better explination of why. How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-06-2010 [eluser]Juan Velandia[/eluser] Hello Guys, thanks a lot. I'll deploy it during the day and I'll let you know how it worked! Best regards! How to change the base_url with depending on the domain (two domains pointing to the same CI deployment) - El Forum - 10-06-2010 [eluser]Juan Velandia[/eluser] The code from both of you (cahva and Nick_MyShuitings) worked perfectly, best regards and thanks a lot! |