Welcome Guest, Not a member yet? Register   Sign In
Dynamic Base Url
#1

[eluser]Gregory Kornblum[/eluser]
Running into issues with the hard-coded method of setting the base url? Yeah, me too. So I made a wiki tips and tricks entry to help you simplify this setting.

http://codeigniter.com/wiki/Dynamic_Base_Url/
#2

[eluser]skunkbad[/eluser]
This seems to be a nice solution, but for me, my development server is set up with all of the websites as sub-directories of http://rbg72.web. I could probably configure my WAMP to run with name based virtual hosting or something, but for me there is something more simple. I have created a checklist for moving to another server. Because other things need to be changed, such as .htaccess and config.php, I always find myself configuring something.
#3

[eluser]WanWizard[/eluser]
In our CMS-to-be, base_url is defined as:
Code:
$config['base_url'] = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . ROOT;

The constant ROOT is defined in index.php, as:
Code:
define('ROOTPATH', realpath(dirname(__FILE__)) . '/');

// installed in the docroot?
if (realpath(dirname(__FILE__)) == $_SERVER['DOCUMENT_ROOT'])
{
    define('ROOT', '/');
}
else
{
    define('ROOT', substr(ROOTPATH, strlen($_SERVER['DOCUMENT_ROOT'])+1));
}

This will handle website installations in subdirectories of the DOCROOT.
#4

[eluser]Gregory Kornblum[/eluser]
Nice, your's is more thorough. That should be included in the framework's next release. What value does the hard-coding provide anyway?
#5

[eluser]Gregory Kornblum[/eluser]
I updated the wiki with your version and gave you credit. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB