This is most easily done by using a subdomain for the staging version, i.e. staging.doman.com
. The folder where you put the CI files isn't super important as the subdomain will be set to use the directory you choose.
You will either need to have complete control over the server or have a service provider that allows you to set up subdomains.
- Expanded Answer -
If you cannot set up a subdomain then your next best option is to use the advice in the documentation on Managing you Applications. It isn't required to use the file structure shown there. In your case try the following.
Create a folder on the same level as application
named staging
.
Into that folder copy all the folders and files normally found in /application
.
Add all application folders and files required by your site. The files in these folders are those that make up the application you are staging.
Make a copy of index.php
(the file at the root of the public folder, i.e. domain.com/index.php
) and name it staging.php
. Both index.php
and staging.php
will be in the same folder.
Edit staging.php
and change the value of $application_folder
to be the absolute path to the staging folder. For example:
$application_folder = '/path/to/domain.com/public_folder/staging';
The path above is an example. You must replace it with the actual path in your server. If you have no idea what the full and absolute path is you can use
$application_folder = dirname(__FILE__).'/staging';
- Browse to the URL
domain.com/staging.php
and you should get your default controller's output. To test that you are actually seeing the staging version of the page temporarily change something in the view file so there can be no doubt.
You will go to other controllers by using the URL domain.com/staging.php/other_controller
.
Change the value of $config['index_page']
in /staging/config/config.php
to staging.php
, e.g.
$config['index_page'] = 'staging.php';
Without the above change redirect()
and many other "helper" functions will not work correctly.
- (Optional?) You can probably edit the main
.htaccess
and add rewrite rules for staging.php
the same way it is done for index.php
. But I will leave that as an exercise for you. (Or for another SO question.)
A final word. It might be necessary to make other configuration changes to accommodate the revised file structure. I tested the answer here but did not go beyond the most basic task of browsing to controllers. Most likely config values for sessions, cookies, and many others will need to be adjusted for the staged version to work correctly. Check out the documentation on Handling Multiple Environments for guidance on making this less painful.