CodeIgniter Forums
How to create a dynamic base url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: How to create a dynamic base url (/showthread.php?tid=62231)



How to create a dynamic base url - webdevron - 06-22-2015

My domain - domain.com
A link on this domain is - domain.com/page

Now I want to access this page from other subdomains like-
sub1.domain.com/page
sub2.domain.com/page
sub3.domain.com/page
...
...
subn.domain.com/page

What is the best way to do this...?

Thank you in advance


RE: How to create a dynamic base url - mwhitney - 06-22-2015

If you want to access the same domain which is currently in use, you simply create your links using one of the URL helper functions, like:
Code:
<a href="<?php echo site_url('page'); ?>">Link to {current_domain}/page</a>