CodeIgniter Forums

Full Version: How do you relocate a C.I. app from local host to a webserver?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

What needs to change for a C.I. app to work properly on a webserver?
My current config for the app is for my local host. I need it to work on something like

I know the default $application_folder in the "index.php" is just "application", but I'm not sure how to set it to recognize the application when it is moved to a different web server.

How would you configure this?


El Forum

[eluser]Ben Edmunds[/eluser]
Most of the time all you have to change is the base_url in the config.php file.

You might also have to turn on mod_rewrite on your sever if you are using an .htaccess file.

El Forum

I point all my file stuff in the headers to base_url, that way if I was changing to a new host... all I have to change is the path in one spot and it works globally!

An example situation is a css file.

In the header for the file path I'd go

<?php echo base_url(); ?>system/application/views/css/style.css

I do that because there is already a trailing slash in the base_url.

El Forum

[eluser]Yoosuf Muhammad[/eluser]
Quote:I know the default $application_folder in the “index.php” is just “application”, but I’m not sure how to set it to recognize the application when it is moved to a different web server.

There is no such, if you see the Powerful CMS Expression Engine version 2, EE lab guys have retained the directory structure as it is same like CodeIgniter. Smile so don't think much security by only moving the Application Directory, make sure that your code is secured.


El Forum

From bitter experience I find that it is far easier to have an exact duplicate (oxymoron?) of all files both on my localhost and webserver. I can confidently upload files without overwriting a localhost version and server version.

To achieve this I define a LOCALHOST constant that I can check and modify data and variables such as config, database, profiler, ini_set('display_errors', 'On'), etc. The list gets bigger on a daily basis Sad

define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);

  $config['base_url']    = 'http://' .$_SERVER['SERVER_NAME'] .'/';

  $config['log_threshold'] = LOCALHOST ? 1 : 0;

  $db['default']['database'] = LOCALHOST ? "dbname_localhost" : "dbname_online";
To install onto your webserver I would temporarily set your PHP error_reporting level to E_ALL and also to display all errors.

El Forum

@John_Betong: Thats what I do and think its the best way to go. Never have to mess with the values again or forgetting to change them before you upload. Set it and forget it. Sure helps with version control too.