![]() |
current_url returns the url from the config, not the real url! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: current_url returns the url from the config, not the real url! (/showthread.php?tid=20541) |
current_url returns the url from the config, not the real url! - El Forum - 07-14-2009 [eluser]Chad Crowell[/eluser] I know from the url helper code that this is by design - What I need is the actual url. I have a site that can be accessed via several subdomains, and based on the subdomain it will show certain info in the header. So, abc.domain.com def.domain.com xyz.domain.com are actually all the same website install and I need CI to actually read the domain name in the address bar, not what is in the config. I have tried lots of options and am extending the current_url function of the URL helper but this code (actually any code where i try to use $_SERVER['HTTP_HOST']; or $_SERVER['REQUEST_URI']; is throwing an error) is giving me this error: A PHP Error was encountered Severity: Notice Message: Undefined index: host Filename: models/my_model.php Line Number: 13 Here is my current function: Code: <?php //enhanced url helper current_url returns the url from the config, not the real url! - El Forum - 07-14-2009 [eluser]Cro_Crx[/eluser] Can you put in the results of print_r($_SERVER) on the page you're getting an error as it may help. current_url returns the url from the config, not the real url! - El Forum - 07-14-2009 [eluser]Chad Crowell[/eluser] Ah that helps - looks like I can use $_SERVER['SERVER_NAME'] to get what I need. Thanks for the pointer. |